¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita+ 1
What is wrong with this code can any one tell me
2 Respuestas
+ 3
Hi, Viraj Yadav !
Why: charctr=1;
Why not: charctr = 0;
In loop. Why theese quotes?
if(ch==’ ‘||ch==’\n’)
Shoulden’t it be:
if (ch == ' ' || ch = '\n')
+ 3
Viraj Yadav I see a few errors.
file*fptr;
should be
FILE *fptr;
getc() returns an int, but ch is declared as char. In order to compare ch with EOF, ch should be declared as an int.
Line 24 needs to use normal single quotes, not backticks.
I think that in line 34 it should subtract 1, not 2 from wrd. Better yet, initialize both wrd and charctr to 0, so that you won't have to subtract 1.
The code formatting could be improved with more customary indentation where you increase the indent where a basic block is nested and then restore the indent back to the containing block at the end of the nested block.