Write a program that accepts a string where multiple spaces
are given in between the words. Print the string ignoring
the multiple spaces.
Example:
Input: “ We Are Student “
Output: "We Are Student"
Answer Posted / vadivel t
#include<stdio.h>
main()
{
char *p, *q, *q1;
p = (char *)malloc(200);
q = (char *)malloc(200);
q1 = q;
printf("ENTER THE SENTENCE: \n");
p = gets(p);
while(*p != '\0')
{
if(*p != ' ' || *(q -1) != ' ')
{
*q++ = *p++;
}
else
p++;
}
*q = '\0';
printf("%s", q1);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How many bytes is a struct in c?
Tell me about low level programming languages.
Can variables be declared anywhere in c?
How do we print only part of a string in c?
Explain what is the difference between #include and #include 'file' ?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What is meant by errors and debugging?
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
Why doesnt that code work?
Explain what is a const pointer?
What is the use of ?
Differentiate call by value and call by reference?
What are the types of bitwise operator?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
How are strings stored in c?