create a string c code example
Example 1: string in c
#include <stdio.h>
int main(void) {
char name[] = "Harry Potter";
printf("%c", *name);
printf("%c", *(name+1));
printf("%c", *(name+7));
char *namePtr;
namePtr = name;
printf("%c", *namePtr);
printf("%c", *(namePtr+1));
printf("%c", *(namePtr+7));
}
Example 2: string in c
#include <stdio.h>
int main()
{
char name[30];
printf("Enter name: ");
fgets(name, sizeof(name), stdin);
printf("Name: ");
puts(name);
return 0;
}
Example 3: declare string in c
char string[20];