Convert char array to int array c++ -


I'm having trouble reading four arrays to read from an array array from the file. Maybe someone can help me . This is my code:

  Four Vector Petron [67]; Int ipetron [67]; Archive = Fopen ("1_0.txt", "r"); For (i = 0; i & lt; 67; i ++) {fscanf (archive, "% c", and vector patron [i]); Printf ("% c", vectorPatron [i]); } Falcos (Archive); For (i = 0; i & lt; 67; i ++) {ipetrons [ii] = ato (and vector patron [ii]); Printf ("% d", iPatrones [i]); }    

This is because atoi is a blank-delimited string When you are giving an indicator for a single char (both are essentially char * , but its purpose and usage is different Are).

Change atoi with iPatrons [i] = call to vectorPatron [i] - '0';

In addition, you can remove the vectorPatrons array, read it in a single char in the first loop, and then iPatrons Assign to the appropriate location in the array.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -