I asked the user for a file with an array and I copy the array from the file to the c[50]
array, also printing out each value as I add the values to the array. Out of curiosity I decided to reprint the values off of the c[50]
array and to my surprise there were totally different numbers (BIG numbers).
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int c[50], k = 0, d[50], i, s;
float r;
FILE * fin;
char filename[15], l;
printf("De el nombre del archivo:\n\n");
scanf("%s", filename);
fin = fopen(filename, "r");
if (fin == NULL) {
printf("\nNo se pudo abrir el archivo.\n");
return 1;
}
fscanf(fin, "%c", & c[k]);
while (!feof(fin)) {
printf("%c", c[k]);
k++;
fscanf(fin, "%c", & c[k]);
}
//s is the size of the array idk why it makes the k double the amount that what it really is but it doubles it.
s = k / 2;
printf("%d\n", s);
for (i = 0; i < s; i++) {
printf("%d ", c[i]);
}
return 0;
}