c++ - how can i save an unknow number integers from a .txt file into an array -
How can I generate a data.txt file contains a large number of integers in two columns.
How can I save these integers in arrays?
is that if you can find it helps sample:
600000 523887 283708 231749 419866 293707 273512 296065 215334 233447 207124 264381 460210 374915 262848 449017 329022 374111 151212 2933 496,970
I'm not doing this but it is tried for some reason ..
#include & lt; Iostream & gt; # Include & lt; Fstream & gt; using namespace std; Int main () {fstream input ("data-of-union-search .txt"); Int i = 0; Float A; Int size = 0; Size = I / 2; While (Input>> One) {i ++; } Int * x = new int [size]; Int * y = new int [size + 1]; For (Int J = 0; J & lt; (size + 1); j ++) {input> gt; X [j]; Input & gt; & Gt; Y [ja]; The court's & lt; & Lt; X [J] K & lt; & Lt; "" & Lt; & Lt; Y [j]'s & lt; & Lt; "" & Lt; & Lt; J & lt; & Lt; Endl; Return 0; }}
To add more elements to an array beyond its capacity , Then you have to A safe solution . std :: vector
is to use push_back
method. std :: vector
with a large size
Comments
Post a Comment