vs2010中的问题??
#include <stdio.h>#include <string.h>
#include <stdlib.h>
#include <conio.h>
int main(void)
{
FILE *stream;
char string[] = "This is a test";
char msg[20];
/* open a file for update */
stream = fopen("DUMMY.FIL", "w+");//在vs2010中为什么程序运行到这里的时候,就出现了问题,说是stream为空,不是w+是可以创建一个文件吗?
if(stream==NULL){
perror("error");
getch();
exit(EXIT_FAILURE);
}
/* write a string into the file */
fwrite(string, strlen(string), 1, stream);
/* seek to the start of the file */
fseek(stream, 0, SEEK_SET);
/* read a string from the file */
fgets(msg, strlen(string)+1, stream);
/* display the string */
printf("%s", msg);
getch();
fclose(stream);
return 0;
}