# define A 100
# define M 100
#include<ctype.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
char a[M];
clrscr();
gets(a);
int k[A][A],r=0,c=0,i,j,l;
for(i=0;i<strlen(a);i++)
{
if(a[i]!=' ')
{
k[r][c]=a[i];
c++;
}
else
{
k[r][c]='\0';
r++;
c=0;
}
}
printf("c=%d \n",c);
printf("r=%d \n",r);
for( i=0;i<=r;i++)
{
printf("%s\n",k[i]);
}
getch();
}
in the above program I want to print each string in different line.
say if the given string is "john is a hardworking student" I'm trying to print this way...
john
is
a
hardworking
student
but my output is coming like this...
j
i
a
h
s
i.e first character of each string in the sentence.
What is the probable error i m making????
plz I'm new to c programming help me!!!
regards

New Topic/Question
Reply



MultiQuote


|