Monday, 19 March 2012

Examples on strings


#include<stdio.h>
#include<conio.h>
void main()
{
char name[25];
clrscr();
printf("enter ur name");
scanf("%s",name);
printf("%s",name);
getch();
}
--Here base add of array is passed to scanf() fx.
--printf()
doesnot print ‘\0’

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char name[25]={'i','n','d','i','a','n','\0'};
int i=0;
clrscr();
while(name[i]!='\0')
{
printf("%c",name[i]);
i++;
}
getch();
}



No comments:

Post a Comment

Total Pageviews

Powered by Blogger.