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
Explain what is the benefit of using an enum rather than a #define constant?
how do you programme Carrier Sense Multiple Access
Can static variables be declared in a header file?
regarding pointers concept
What is the difference between struct and typedef struct in c?
What are identifiers c?
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
What is the use of bit field?
Explain 'far' and 'near' pointers in c.
How does selection sort work in c?
What are external variables in c?
What is extern c used for?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
Why do we use namespace feature?
What is a pointer and how it is initialized?