hi i'm having two problems which i believe if i solve the first one the second will work(plus a little concern). i'm trying to write a program that opens a file(test.txt), and types Testing in it. at first it would give me an error when i ran it, i manually created the file and that solved the problem. now i'm trying to use fprintf to write to the file. but it won't work. i open the file after i run the program and its blank. because of that ofcourse i can't scan the file just to see whats inside it as a test. i'm trying two functions: fscanf and fgetc
using fscanf:
Code:
/* File I/O
*/
#include <stdio.h>
int main() {
    FILE *test;
    char str[100];
    
    test = fopen("c:\\test.txt", "w+");
    fprintf(test, "Testing");
    fscanf(test, "%s", str);
    fclose(test);
    printf("str: %s", str);
    getchar();
    return 0;
}
and to use fgetc replace
Code:
    fscanf(test, "%s", str);
with
Code:
fgetc(str, 100, test)
my to problems(summerized) are:
1. why doesn't "w+" create the file?
2. why isn't fprintf write to the file?
my little concern is: getchar() is supposed to pause the program until i hit enter, why doesn't it work with some programs? like this one?