24) Explain About Strings With Program?: 1 G Viswanath, M.Tech, (PH.D), Associate Professor, Vemu Institute of Technology
24) Explain About Strings With Program?: 1 G Viswanath, M.Tech, (PH.D), Associate Professor, Vemu Institute of Technology
24) Explain About Strings With Program?: 1 G Viswanath, M.Tech, (PH.D), Associate Professor, Vemu Institute of Technology
Declaration of strings:-
Before we actually work with strings, we need to declare them first.
Strings are declared in a similar manner as arrays. Only difference is that, strings are of chartype.
char s[5];
Initialization of strings:-
In C, string can be initialized in a number of different ways.
For convenience and ease, both initialization and declaration are done in the same step.
char c[] = "abcd";
OR,
char c[50] = "abcd";
OR,
char c[] = {'a', 'b', 'c', 'd', '\0'};
OR,
char c[5] = {'a', 'b', 'c', 'd', '\0'};
5
G VISWANATH, M.TECH, (Ph.D), ASSOCIATE PROFESSOR, VEMU INSTITUTE OF TECHNOLOGY