What is wrong with this code such that it doesnt produce
the input reversed?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char Space = ' ';
char LineOfText;
float count;
LineOfText = getchar();
while ((LineOfText = getchar()) != '/n');
{
count = strlen(LineOfText) - 1;
while (count >= 0)
{
putchar(LineOfText[count]);
count--;
}
}
getchar();
return 0;
}
Answer Posted / sanjay bhosale
LineOfText is not an array of characters.
first while loop only stores '/n' in lineOfText.
We cant apply strlen on character we should pass the address of character array to it.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between union and structure in c?
what is event driven software and what is procedural driven software?
What is a macro in c preprocessor?
How the c program is executed?
What is a c token and types of c tokens?
How do you print an address?
What are external variables in c?
What is null pointer in c?
What is the use of putchar function?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
What does *p++ do? What does it point to?
What is the use of getchar() function?
Are comments included during the compilation stage and placed in the EXE file as well?
How many bytes is a struct in c?
What is call by reference in functions?