I'm writing a small function to retrieve the first line from a C style string passed (I have my own reasons). Here's the code so far, in essence:
Code:
char* getaline(char const* const from, char* to) {
char line = 0;
for(unsigned int pos = 0; pos < strlen(from); pos++) {
if(from[pos] == '\n') break;
cout << "\tfrom[pos] = \"" << from[pos] << "\"";
line += from[pos];
cout << "\t\tline = \"" << line << "\"\n";
};
}
This is really odd. The character inside the quotes after 'from[pos] = ' is what I would expect it to be, but then in the second column (displaying what's in the buffer "line") is a mix of random symbols, one per line, including a musical note and an up-down arrow.
Can someone tell me what's going on?