I need to know how to remove spaces from a string using pointers in C++. Since I'm in senior year in school I'n not used to quite complex programming. I tried doing this program but I think I'm totally hopelessly terrible wth pointers (I was out sick, the day my teacher did pointers) Can anyone help?
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iostream.h>
void rem_spc(char *);
void main()
{
char str[20];
cout<<"\nEnter String :";
gets(str);
rem_spc(str);
getch();
}
void rem_spc(char *t)
{
char *str1[30];
int i=0;
int j=0;
while(*t!='\0')
{
if(*t!=" ") // It gives an error here " cannot convert char to char* "
*str1[i] = *t;
t++;
i++;
}
cout<<endl;
while(*str1!='\0')
cout<<*str1;
}