0

Can some one tell me where the string is stored ,and there is only singed char c variable please explain "" my understanding is that it reads a character checks it and prints it then read the coming one !!

#include<stdio.h>
#include<ctype.h>

main(){
  int cnt=0;
  signed  char c;

  printf("***Print Identifiers***\n\n");
  printf("Type text,terminate with EOF Z orD");

  c=getchar();

  while(c!=EOF){
        while(isspace(c))
                  c=getchar();

         if(isalpha(c)){
             while(isalnum(c)){
                 putchar(c);

                 c=getchar();

             }
             printf("\n");
             cnt++;



         }

         else if (c==EOF)
             break;

             else{
                printf("Illegal charavter %c\n",c);
                c=getchar();

             }



  }

        printf("Number of Identifiers =%d\n",cnt);
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Adak
0

There is no string in your program, at all. A bunch of letters are not a string, in C. They must have an end of string char, to mark the end of the string: '\0'. Only then are letters, elevated up to string status.

A single char can never be a string. It must have at least one char, AND the end of string char (which you can not see on the screen, normally. Use your debugger to see it).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.