How do I remove Space from Given String in C with example Code

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

int main()
{

char testString[] = "Kapil Thakar";

char *outString = (char *) malloc (sizeof(testString));

int i = 0;
for(i=0 ; i<strlen(testString); i++)
{

  if ( *(testString + i) != ' ')

  {
printf("%c" , *(outString + i) = *(testString + i));
  } 

}

printf("\n");

getch();
return 0;

}


OUTPUT:

Share on Google Plus

About Kapil Thakar

"I am Kapil Thakar, an Embedded Engineer cum Blogger wants to learn new things. I love to share my knowledge solutions to the problems. Interested in Blogging, Creative-Writing, SEO, Website Creation, Video Making, Editing, Affiliation Programs, Online Making Money."
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment

Related Posts Plugin for WordPress, Blogger...