Hmm... I seem to have more questions:
Code:
#include <stdio.h>
//prototypes
int start_binary (void);
void scope_test (void);
int main (void)
{
start_binary ();
return (0);
}
int start_binary (void)
{
char x[10] = "ABCDEFGHIJ";
FILE *fp = fopen ("prime_binary.txt", "wb");
if (!fp)
{
printf ("\n\nERROR! Not enough memory!\n\n");
return (0);
}
fwrite (x, sizeof (x[0]), sizeof (x) / sizeof (x[0]), fp);
scope_test ();
fclose (fp);
printf ("\n\n");
return (0);
}
void scope_test (void)
{
int loop = 0;
char x[10] = "JIHGFEDCBA";
FILE *fp = fopen ("prime_binary.txt", "a");
for (loop = 0; loop < 10; loop++)
{
fprintf (fp, "%c", x[loop]);
}
fclose (fp);
}
(If there are any syntax errors, I apologize. I'm on a seperate computer and had to retype it here)
When I run this program:
1) Why doesn't Windows crash when I attempt to open a file twice (especially in different modes)?
2) Why do I only have 1 line instead of 2 in my text file after this program is finished running? I was trying to "append" in my scope_test function to see what would happen.
Thanks!
mw