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
Why clrscr is used in c?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
What does it mean when a pointer is used in an if statement?
How can I swap two values without using a temporary?
What's the right way to use errno?
Explain what is #line used for?
Why cant I open a file by its explicit path?
regarding pointers concept
What does c in a circle mean?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What are data types in c language?
When should a type cast be used?
Why C language is a procedural language?
How can I find out the size of a file, prior to reading it in?
The __________ attribute is used to announce variables based on definitions of columns in a table?