getline dosn't work

i have problem with reading the line of file;

the file: https://pastebin.com/D9L1ScWW

file testing: file1 contain "noting but everything";
file2 contain "nothing but nor";

the problem exist because getline(fs2, line2) (line 8)(and line 7) don't want to execute properly
Last edited on
I don't see a single header file in that. I'm not inclined to troubleshoot code that can't be compiled without knowing what headers you are using.

Not posting your code here is really not a good way to get help.
This is undefined behavior:

 
openfiles(*argv, *++argv);

It should be
1
2
char *prev = *argv++;
openfiles(prev, *argv); // might want to ensure that *argv isn't NULL 

Last edited on
@dutch You can see that i included test in openfiles() function check does two files are opened
@Furry Guy whole code: https://pastebin.com/Pq08gYmK
I don't download code from a 3rd party site.
You need to use an endl (or at least a flush) after printing the "executed 0;" string, otherwise you may not see it. In other words, it's probably not stopping at the getline, but a little later on (either with the diff_chars access or with the print_line function).

BTW, "undefined behavior" can work on one system and not work on another (or even potentially with a compiler update). The proper way to call openfiles is something like I've shown.
Last edited on
Topic archived. No new replies allowed.