Home > Back-end >  [C language help]
[C language help]

Time:10-10

How to judge a blank line in the program,,, just want to ask, someone can be solved well,,

CodePudding user response:

Use getchar, ch=getchar; Ch==' ';

CodePudding user response:

Or ch==32 ascll judgment can also directly

CodePudding user response:

refer to the second floor beginners side response:
or ch==32 ascll judgment can also directly

Ok thank you! I try to

CodePudding user response:

For example
Char c [256];
Char * p=gets (c, sizeof (c); Stdin);//here in the standard input, for example, can change to the file pointer
if (p!=NULL & amp; & C [0]=='\ n') printf (" empty line ");

CodePudding user response:

See how empty line defines the
Only a carriage return line is, of course,
So this line only eight Spaces count
This line has two TAB count

The fgets reads a line, whether all of the characters of this line is blank characters, namely the above said Spaces, TAB and press enter
The fgets can get return in reading

CodePudding user response:

Regular expression ^ \ s * $

CodePudding user response:

Fun
reference 5 floor response:
see how empty line defines the
Only a carriage return line is, of course,
So this line only eight Spaces count
This line has two TAB count

The fgets reads a line, whether all of the characters of this line is blank characters, namely the above said Spaces, TAB and press enter
The fgets can get return in reading

Thank you I try!

CodePudding user response:

reference 4 floor qybao response:
for example
Char c [256];
Char * p=gets (c, sizeof (c); Stdin);//here in the standard input, for example, can change to the file pointer
if (p!=NULL & amp; & C [0]=='\ n') printf (" empty line ");

Ok I try!

CodePudding user response:

refer to 6th floor proorck2019 response:
regular expression ^ \ s * $

I learn to
  • Related