I'm trying to manipulate a string by removing the first character or word before a space, and keeping the rest of the sentence.
For example:
char *sentence = {"I am home"};
should become: "am home"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
char *sentence = {"I am home"};
int space_cnt = 0;
char *p = sentence;
char *copy;
printf("%s\n ", sentence);
for (int k=0; k<strlen(sentence); k++) {
if (space_cnt = 0 && ((p=strchr(sentence, ' ')) != NULL)) {
space_cnt = 1;
}
else if (space_cnt = 1) {
*copy++ = *p;
}
}
printf("COPY: %s\n", copy);
return (EXIT_SUCCESS);
}
Current output:
I am home
COPY: 2�