#include <stdlib.h>
#include <string.h>
#include<stdio.h>
#include<conio.h>
int main()
{
char name[100][30];
int i,n,j,scount;
char ch[30];
int arr[10];
int k=0;
scount=0,j=0;
printf("\nEnter The no. Lines : ");
scanf("%d",&n);
for(i=0;i<n;i++)
scanf(" %[^\n]%*c",name[i]); // storing multiple line on 2d array
for(i=0;i<n;i++)
{
strcpy(ch,name[i]); //copying string to temporary char array ch.
printf("%s\n",ch);
for(j=0;ch[j]!=0;j++) //this is space count logic upto first alphabet character comes
{
if(ch[j]=32) // ascii of space
scount++;
}
printf("\n%d",scount);
scount=0;
//printf("\n%s",name[i]);
}
getch();
}
Editor is loading...