Problem
Write a program in c language which will determine the user input string length and size.Solution - Code
#include<stdio.h>#include<conio.h>
#include<string.h>
main()
{
char sname[30];
char fname[30];
int i,a,b,c,d;
printf("Enter student name : ");
gets(sname);
printf("\n");
printf ("Enter father name : ");
gets(fname);
printf("\n");
a = strlen(sname);
b = sizeof(sname);
printf("\nstring length & string size of %s = %d\t%d\n\n",sname,a,b);
c = strlen(fname);
d = sizeof(fname);
printf("string length & string size of %s = %d\t%d\n\n",fname,c,d);
printf("\n");
system("pause");
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.