, scanf:
scanf("%s", z);
...
if(z[m] != ' '){
scanf ("% s" ...) always breaks in symbol space, so yours , if ever, is true . Better use fgets to read from stdin,
#define MAXINPUT 80
char line[MAXINPUT];
for(j=0; j<7; j++) {
printf("Enter a string:\n");
if( fgets( line, 80, stdin ) )
{
char *c=line;
if( strchr(line,'\n') ) *strchr(line,'\n')=0;
while( *c )
{
if( *c!=' ' )
++charcount;
++c;
}
}
}
Or if you want a WHITE space, take
#include <ctype.h>
...
if( !isspace(*c) )
source
share