/* remove spaces from a given string */
#include <stdio.h>
void removeSpaces(char *str)
{
int count =0;
int i;
for (i =0; str[i] != '\0';i++){
if(str[i] != ' ')
str[count++]=str[i];
}
str[count] = '\0';
}
int main()
{
char str[] = "A w eso m e ";
removeSpaces(str);
printf("result string is %s\n", str);
return 0;
}
#include <stdio.h>
void removeSpaces(char *str)
{
int count =0;
int i;
for (i =0; str[i] != '\0';i++){
if(str[i] != ' ')
str[count++]=str[i];
}
str[count] = '\0';
}
int main()
{
char str[] = "A w eso m e ";
removeSpaces(str);
printf("result string is %s\n", str);
return 0;
}
No comments:
Post a Comment