|
-
Aug 25th, 2001, 10:48 AM
#1
Thread Starter
Hyperactive Member
Writing to Files in C
Right i got this code
Code:
#include "stdafx.h"
#include "stdio.h"
int main()
{
int print1;
FILE *stream, *fopen(10);
stream = fopen("input.ini", "w");
printf("What would yo ulike to write?");
scanf("%i", print1);
fprintf("%i", &print1);
return(0);
}
as you have most probalbly guessed, i am v new at C, and am wondering why this is returning these DEBUG results
C:\My Coding Stuff\C\oepning a file\oepning a file.cpp(9) : error C2059: syntax error : 'constant'
C:\My Coding Stuff\C\oepning a file\oepning a file.cpp(11) : error C2660: 'fopen' : function does not take 2 parameters
C:\My Coding Stuff\C\oepning a file\oepning a file.cpp(14) : error C2664: 'fprintf' : cannot convert parameter 1 from 'char [3]' to 'struct _iobuf *'
thanx
-
Aug 25th, 2001, 11:58 AM
#2
Try this instead.
Code:
int print1;
FILE *stream;
stream = fopen("input.ini", "w");
printf("What would yo ulike to write?");
scanf("%d", &print1);
fprintf( stream, "%d", print1);
return 0;
-
Aug 25th, 2001, 02:58 PM
#3
Frenzied Member
Also change
#include "stdio.h"
to
#include <stdio.h>
because it is a system header.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|