-
Notifications
You must be signed in to change notification settings - Fork 0
/
String.c
47 lines (34 loc) · 1018 Bytes
/
String.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
int main(){
char str1[6] = "hello";
char str2[ ] = "World";
printf("The string is : s1(%s)& s2(%s)\n",str1,str2);
char str3[6] = {'h','e','l','l','o','\0'};
char str4[ ] = {'w','o','r','l','d','\0'};
printf("The string is:s3(%s) & (%s)\n",str3,str4);
/*
strlen() - get length of a string
strcat() - merge two strings
strcpy() - copy one string to another
strlwr() - convert string to lower case
strupr() - convert string to upper case
strrev() - reverse string
strcmp() - compare two strings
*/
char first_name[25];
int age;
printf("Enter your first name and age: \n");
scanf("%s %d", first_name, &age);
printf("\nHi, %s. Your age is %d", first_name, age);
char city[40];
printf(" Enter your favorite city: ");
gets(city);
// Note: for safety, use
// fgets(city, 40, stdin);
fputs(city, stdout);
printf(" is a fun city.");
// Note: for safety, use
// fgets(city, 40, stdin);
puts(city);
return 0;
}