-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11_Strings.c
More file actions
55 lines (35 loc) · 991 Bytes
/
11_Strings.c
File metadata and controls
55 lines (35 loc) · 991 Bytes
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
48
49
50
51
52
53
54
55
#include <stdio.h>
/*
Strings : A character array terminated by a '\0'(null character)
null character denotes string termination
Initializing
char name[] = {'A','R','P','I','T','A'};
char name[] = "arpita";
String Format Specifier: %s
char name[]="Arpita";
printf("%s",name);
IMPORTANT!!!...............
scanf() cannot input multi-word strings with spaces
here,
gets() & puts() come into picture
String Functions:
fgets(str,n,file): stops when n-1 chars input or new line is entered
puts(str): output a string
String using Pointers:
char *str = "Hello World";
Store string in memory & the assigned address is stored in the char pointer 'str'
char *str = "Hello World"; //can be reinitialized
char str[]= "Hello World"; //cannot be reinitialized
*/
int main()
{
/*char name[] = "Arpita";
printf("%s", name);
char name[50];
scanf("%s",name);
printf("Your name is: %s",name);*/
char str[100];
fgets(str,100,stdin);
puts(str);
return 0;
}