This is probably a very newbish question, but can I fix this so that any characters (except \r) are added to my new string ucontents? Just now it only add characters up until the \r. I want to add characters after \r too.
void to_unix_line_endings(char* contents, char* ucontents) { int i; for (i = 0; i < strlen(contents); i++) { if(contents[i] != '\r') { ucontents[i] = contents[i]; } } } char out[5000]; to_unix_line_endings("spaghettiand\rmeatballs", out); printf("%s\n", out); // Prints "spaghettiand". I want "spaghettiandmeatballs". Thanks.
ucontents[i]: use other index variable instead ofi. and null-terminator add to end.