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
What is C language ?
What is indirection? How many levels of pointers can you have?
What is use of integral promotions in c?
What is structure padding and packing in c?
Are the variables argc and argv are always local to main?
What is the code for 3 questions and answer check in VisualBasic.Net?
Is it possible to initialize a variable at the time it was declared?
What does #pragma once mean?
What is use of bit field?
What is else if ladder?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
How can I recover the file name given an open stream?
List out few of the applications that make use of Multilinked Structures?
What are header files and explain what are its uses in c programming?
What is %lu in c?