Dude, you guys rock. I still can't believe i made that small error with the &. Now i have one problem it opens, it reads, but the printing does not work.
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define MAX_CHAR 40
#define MAX_ARRAY 500
int main(void)
{
FILE *inp, *outp;
char instring[MAX_CHAR], outstring[MAX_CHAR];
double in_array[MAX_ARRAY];
double current_status;
int i=0;
int num;
printf("please enter a file you would like to use.");
scanf("%s", instring);
printf("please enter a file you would like to ouput to");
scanf("%s", outstring);
inp = fopen(instring, "r");
outp = fopen(outstring, "w");
if( inp == NULL || outp == NULL )
{
printf("Error: Could not open one or more required files.");
return 0;
}
//read the text file
while(fscanf(inp, "%lf",¤t_status) != EOF)
{
num += 1;
in_array[num -1] = current_status;
}
printf("I read %i numbers", num);
//print the old data to the new text file
for(i = 0; i<num; i++)
{
//there hase to be a problem with this printf statement. it doesn't print to the file.
fprintf(inp, "%f", in_array[i]);
//added this to see if it really was print the correct number and it is.
printf("current number being printed is %f", in_array[i]);
}
printf("I printed %i numbers", i);
fclose(inp);
fclose(outp);
}