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 can I make sure that my program is the only one accessing a file?
Can a pointer point to null?
write a program to find out prime number using sieve case?
How many keywords are there in c?
Why isn't it being handled properly?
What is an endless loop?
Why main is used in c?
What is typedef?
What are local variables c?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
What is the difference between exit() and _exit() function?
Can we assign string to char pointer?
Explain the difference between null pointer and void pointer.
How to throw some light on the b tree?
Array is an lvalue or not?