Program To Accept A Line Of Text Into A String Array And Then Display Copy Each Word Into Each Row Of A 2D String Array
/* Program To Accept A Line Of Text Into A String Array And Then Display Copy Each Word Into Each Row Of A 2D String Array. */ #include
#include
void main() { char text[80],word[20][30]; int i,j=0,k=0,sz; clrscr(); printf("\n enter a line of text \n"); gets(text); for( i=0;text[i]!='\0';i++ ) { if( text[i]!=' ' ) { word[j][k]=text[i]; k++; } else if( text[i+1]!=' ' ) { word[j][k]='\0'; j++; k=0; } } if( text[i-1]!=' ' ) word[j][k]!='\0'; /* assign null chraracter at the end of last word provided line of text doesnot end with a space */ sz=j+1; printf("no.of words=%d",sz); for( i=0;i
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/