String concatenation involves joining two strings together to form a longer
string. This operation is commonly performed using the strcat function.
Reading an entire line of input, including spaces, requires special input
functions. Standard input functions such as scanf stop reading at whitespace,
so functions like fgets are used for whole-line input.
string. This operation is commonly performed using the strcat function.
Reading an entire line of input, including spaces, requires special input
functions. Standard input functions such as scanf stop reading at whitespace,
so functions like fgets are used for whole-line input.
SYNTAX:
fgets(line, 50, stdin);
EXAMPLE:
#include <stdio.h>
#include <string.h>
int main() {
char s1[20] = "Coca";
char s2[20] = "Cola";
strcat(s1, s2);
printf("Full Brand: %s", s1);
return 0;
}
EXAMPLE:
#include <stdio.h>
int main() {
char fullName[30];
scanf("%s", fullName);
printf("Result: %s\n", fullName);
return 0;
}
EXAMPLE:
#include <stdio.h>
int main() {
char name[20];
printf("Enter full brand name: ");
fgets(name, 20, stdin);
printf("The name is: %s", name);
return 0;
}