0% found this document useful (0 votes)
4 views4 pages

Understanding String Variables in C

The document discusses string variables in programming, highlighting character constants and variables, as well as string constants and their declarations. It also covers string library functions such as strcpy, strcmp, strcat, strlen, and substr. These functions are essential for manipulating and handling strings in code.

Uploaded by

Md Nahid Hasan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Understanding String Variables in C

The document discusses string variables in programming, highlighting character constants and variables, as well as string constants and their declarations. It also covers string library functions such as strcpy, strcmp, strcat, strlen, and substr. These functions are essential for manipulating and handling strings in code.

Uploaded by

Md Nahid Hasan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

String variables

Single Character
• ‘a’, ‘X’, or ‘5’ are examples of character constant.
• Character variables –
char symbol;
symbol = ‘a’;
symbol = ‘5’;
• Printing character variable
– printf (“%c”, symbol), putch(symbol)
• Reading character from keyboard
– getchar(), getch()
String constant
• Null character at the end of an character array
• Examples - “Hello”, “32.98”, “-?3c”, “X” .
• Declaration
– char name[10];
– char *name;
• Initialization
– name = “mamun”;
• char name[] = “mamun”;
String library function
#include <string.h>
* strcpy(dest_vav, src_var)
*strcmp(str1,str2). Returns 0 if equal
*strcat(str1, str2). str2 is appended with str1.
* strlen(str_var) return the length of str_var
excluding null (\0) character.
*substr(des_var, src_var, offset, length)

You might also like