Strings in C Part – 1
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// Program for String
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char name[20]; // String
int i=0;
system("cls");
printf("Enter your Name: ");
//scanf("%s",name); // not allowed space
gets(name);
puts(name);
//printf("%s",name);
// while(name[i]!='\0')
// {
// printf("%c",name[i]);
// i++;
// }
return 0;
}Program 2
// Program for String
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char str[50];
int len,i;
system("cls");
printf("Enter a String");
gets(str);
puts(str);
// using inbuild function
// len=strlen(str);
// printf("Length of string is %d : ",len);
len=0;
// without using inbuild function
i=0;
while(str[i]!='\0')
{
i++;
}
printf("Length of String is %d: ",i);
return 0;
}
You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

