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 “ Note: one .=1 Space
Output: "We Are Student"
Answer Posted / vadivel t
Hi all,
Its enough to have this much length of code below. And I
feel no need to have any temp variables(but i used one temp
pointer).
#include<stdio.h>
main()
{
char *p, *q, *q1;
p = (char *)malloc(100);
q = (char *)malloc(100);
q1 = q;
printf("ENTER THE SENTENCE WITH MULTIPLE SPACES: \n");
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 | 1 No |
Post New Answer View All Answers
What is realloc in c?
List out few of the applications that make use of Multilinked Structures?
What do you mean by dynamic memory allocation in c?
What is a volatile keyword in c?
Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
Explain how can a program be made to print the name of a source file where an error occurs?
What is formal argument?
i got 75% in all semester am i eligible for your company
What are the storage classes in C?
What is a buffer in c?
What is the difference between a free-standing and a hosted environment?
What are disadvantages of C language.
Why we use stdio h in c?
What type of function is main ()?