38.4k views
2 votes
Overview In C, a string is simply an array of characters. We have used literal strings all along – the stuff in between the quotes in a printf is a literal string. A literal string can be stored in a character array for later use, just as you would store the value 12 in an int variable. The string library string.h provides several functions for manipulation strings. In this week’s lab, you will see static and dynamic ways of storing strings, and write your own versions of the string library function strcpy(), which copies one string into another.

User Pbz
by
3.3k points

1 Answer

6 votes

#include<stdio.h>

#include<string.h>

int main() {

char str1[100];

char str2[100];

printf("\\Enter the String 1 : ");

gets(str1);

strcpy(str2, str1);

printf("\\Copied String : %s", str2);

return (0);

}

User Yan Brunet
by
4.0k points