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 / jyotsna

/* Assume ' ' at the place of '.' */

#include<conio.h>
#include<stdio.h>
void main()
{
char *s="Hello...this...is...jyotsna";
int i=0;
clrscr();

while(*s!='\0')
{
if(*s!='.')
{
printf("%c",*s);
i=0;
s++;
}
else
{
while(*s=='.')
s++;

printf(".");
}
}
getch();
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is huge pointer in c?

585


What is this infamous null pointer, anyway?

610


What is I ++ in c programming?

626


Which built-in library function can be used to match a patter from the string?

747


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

695






Why is struct padding needed?

631


What is a stream?

651


Mention four important string handling functions in c languages .

630


What is p in text message?

540


what is the function of pragma directive in c?

626


What will be the outcome of the following conditional statement if the value of variable s is 10?

767


What is local and global variable in c?

616


What does it mean when a pointer is used in an if statement?

602


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

580


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

1856