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
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
What is difference between Structure and Unions?
What are the different properties of variable number of arguments?
Write a program of prime number using recursion.
Explain the difference between strcpy() and memcpy() function?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
How many identifiers are there in c?
What is sizeof c?
What is the general form of a C program?
Define Array of pointers.
Why do we use main function?
What are pointers really good for, anyway?
What does c value mean?
Write a program to find the biggest number of three numbers in c?
a c code by using memory allocation for add ,multiply of sprase matrixes