binsky3333
New Member
- Joined
- Jul 5, 2007
- Messages
- 643 (0.10/day)
System Name | Green Machine |
---|---|
Processor | Intel e6420@ 2.13GHz |
Motherboard | ASUS p5n32-e -sli |
Cooling | 4x80mm fans |
Memory | 4gb G skill ddr2-800 |
Video Card(s) | 2 EVGA Geforce 8800GTS 320MB |
Storage | 1 Western digital 500gb sata |
Display(s) | Dell e207wfp |
Case | Apevia x-cruiser green |
Audio Device(s) | X-fi Xtreme gamer |
Power Supply | BFG 800watt |
Software | Windows vista ultimate 64bit |
Ok hi everyone, i am currently making a very simple C word processor where you can type in the file name of a text file you want to open, then add text to, though i am having some problems with opening a file. Here is what i have so far:
The problem i am having is with the fopen("%s", "a+w", open). The program will not compile because of this... I get... 178 C:\Dev-Cpp\include\stdio.h too many arguments to function `FILE* fopen(const char*, const char*)' . Basically the %s is a reading variable input. Someone types in the filename, then it is inserted into the position of %s so the user can open the file... Why wont this work what am i doing wrong?
Code:
#include <stdio.h>
int main()
{
char write[256];
char open[128];
printf("Please enter the name of the file you want to open.(Does not need to exsist)\n");
fgets ( open, 128, stdin );
FILE *fp;
fp=fopen("%s", "a+w", open);
printf("Please enter the text you would like to write to the file\n");
fgets ( write, 256, stdin );
fprintf(fp, "%s\n", write);
printf("Complete\n");
getchar();
}
The problem i am having is with the fopen("%s", "a+w", open). The program will not compile because of this... I get... 178 C:\Dev-Cpp\include\stdio.h too many arguments to function `FILE* fopen(const char*, const char*)' . Basically the %s is a reading variable input. Someone types in the filename, then it is inserted into the position of %s so the user can open the file... Why wont this work what am i doing wrong?
Last edited: