Im having a little trouble. I have to write a program that will input a string of positive integers terminated by a negative integer and then sort it.I have done the sorting part and it works fine.But the part that the string continues to get integers unless a negative integer entered is causing problem. Here is my code which i wrote to get the string..Please tell me what is the problem with my code?
void getLine(string line)
for (int m = 0 ; m < line.length() ; m++)
if (str[k] == '-')
line = line.substr(0,k-1);
well you can use getline with '-' as the delimiter so you don't need to check for the negative. also your function is returning void. are you sure you want to do that? I believe you would want to return the string to the function that called this function.