I just made this function a miniute ago, and its suppost to remove the space off of the beginning of a string. It compiles fine, but doesn't seem to do anything at all to the string. Im not sure why its not working. Thanks! Also, I was searching the forum for a possiable answer to this before, and one of the posts made a reference to 'isspace()'. What header does that function lie in?
Code:
//in main:
command[256]=a_remove_space(command);
cout << command;
//the function
char a_remove_space(char string[])
{
char newstring[256];
int i2=0; //used in local embedded loop
int last_slot=0; //the slot of the string that a space is no longer found
bool done=false;
//remove spaces from string
for(i=0;i<(strlen(newstring));i++)
{
if(string[i]!='/0') //if we found a slot without a space then continue
{
last_slot=i; //get the slot of the string that we found the letter
for(i2=last_slot;i2<(strlen(string));i2++) //initialize a new loop to re-fill the array
{
newstring[i2-last_slot]=string[i2]; //refill the array
done=true;
}
}
if(done==true) break; //exit the base for...loop if done is set to true
}
return newstring[256];
}
In main, it prints the string just as it was before, with the spaces in the front. Thanks for any help!