Original Code:
#include <stdio.h>
int main()
{
char string[50],
string1[] = {'A', 'c', 'i', 'd', '\0'},
*string2 = "base";
printf("What is your name?\n");
gets(string);
printf("Your name is: \n");
puts(string);
printf("%ss and %ss", string1, string2);
return 0;
}
Output:
I have learned that there is no String class in C as there is in Java, so you must use a char array. I have learned two ways that you can create a string in C. To print a string, you need to use "%s" and not something like "%c".

No comments:
Post a Comment