oh ok i attempted to use this
while((j = fscanf(pfile, "%d", &num)) !=EOF){
data_in[i] = num;
i++;
}
Type: Posts; User: bigparker
oh ok i attempted to use this
while((j = fscanf(pfile, "%d", &num)) !=EOF){
data_in[i] = num;
i++;
}
oh ok...I got that straight...it was because I had MAX set to a value greater than the number of integers in my input file...
thanks...that got rid of the seg fault. Do you guys have any idea of why the the program would only print the last value in my input file? its prints 421 repeatedly...
# define MAX 1000...
Not to seem basic, but how do i test to be sure that i dont run past the end of my buffer?
int main(){
printf("Cake");
int data_in[100];
FILE *pfile;
pfile = fopen("input.txt", "r");
int i=0;
int num=0;
do{
int main(){
printf("Cake");
int data_in[100];
FILE *pfile;
pfile = fopen("input.txt", "r");
int i=0;
int k=0;
int num=0;
do{
I have no other function in the program. I broke up all of my declarations and initialized all the variables to zero, but the seg fault is still there...
Can someone help me figure out why I am getting a seg fault at run time...
#include <stdio.h>
#include <stdlib.h>