I have to get numbers from file and some of them are negative. So, how can I do that? (C++)
Now I'm trying just this (without something special):
U1.txt file:
4 5 -1 6 -2
My code:
ifstream fd(FD); int n1,n2,n3,n4,n5; fd>>n1>>n2>>n3>>n4>>n5;
Your code is basically correct, except for that typo with n4 missing. This:
ifstream fd("U1.txt"); int n1,n2,n3,n4,n5; fd>>n1>>n2>>n3>>n4>>n5;
Will do what you expect, modulo error conditions.
Your code is basically correct, except for that typo with n4 missing. This:
Will do what you expect, modulo error conditions.