men c string 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: c language string
#include<stdio.h>
#include<conio.h>
void main(){
char string[50];
clrscr();
printf("ENTER STRING:");
gets(s);
printf("TYPED STRING:%s",string);
getch();
}
Example 3: string in c programming
#include <stdio.h>
int main(){
char name[10];
printf("What is your name: \n");
scanf("%s", name);
printf("Hello, %s!\n", name);
}