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


Please Help Members By Posting Answers For Below Questions

Why clrscr is used in c?

813


How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

16106


What does it mean when a pointer is used in an if statement?

888


How can I swap two values without using a temporary?

870


What's the right way to use errno?

887


Explain what is #line used for?

830


Why cant I open a file by its explicit path?

835


regarding pointers concept

1834


What does c in a circle mean?

804


Is it possible to use curly brackets ({}) to enclose single line code in c program?

1080


What are data types in c language?

832


When should a type cast be used?

799


Why C language is a procedural language?

842


How can I find out the size of a file, prior to reading it in?

919


The __________ attribute is used to announce variables based on definitions of columns in a table?

988