Apr 17, 2013 at 10:26pm UTC
What are definitions of a and aa? Why did you decide that a has 30 characters?
Apr 17, 2013 at 10:31pm UTC
Sorry, I didn't include the declarations.
It's for an algorithm problem. I store the input in a and b then parse after and store the results on aa and bb The problem is only with the getline, if I'm not mistaken.
Last edited on
Apr 17, 2013 at 10:32pm UTC
Apr 17, 2013 at 11:33pm UTC
> Why did you decide that a has 30 characters?
Also, ¿where do you set the size of `aa'?
Use better identifiers
Apr 18, 2013 at 2:10am UTC
will be empty after the
if the number extracted is followed by a newline.
doesn't represent what you think it represents. (had to add the newline to preserve the spaces.)
You are reusing the i from the outer loop in the loop body. Bad practice.
Actually describing what your code is intended to do would be helpful, as would providing a compilable example that exhibits the problem.
Last edited on
Apr 18, 2013 at 2:13am UTC
Apr 18, 2013 at 5:07am UTC
Also scanf returns a value - you should always assign & test it to see how successful it was before using any variable read in by it.
Why are you using scanf in a C++ program - learn how to use cin or stringstreams.
Apr 18, 2013 at 10:09am UTC
on line 7 you set
, which means your have an infinite loop
Apr 18, 2013 at 4:02pm UTC
I've fixed that, however it has nothing to do with the segfault. It seems to happen in the getline statement, because when running the above code it prints '1', but not '2'.