|
-
May 19th, 2001, 11:17 AM
#1
Thread Starter
Hyperactive Member
open file
Code:
#include "iostream.h"
#include "fstream.h"
#include "stdafx.h"
int getdir();
int getdir()
{
int i;
ofstream out("C:/Matt/text3.txt");
if(!out) {
MessageBox(NULL,"Cannot open output file","Error",MB_OK);
return 1;
}
for(i=0;i<256; i++) out.put((char) i);
out.close();
return 0;
}
im using MVC++ and i get errors. This worked on my old compiler but not MS's. What am I doing wrong here? Thanks
Matt 
-
May 19th, 2001, 11:51 AM
#2
Monday Morning Lunatic
Code:
#include "iostream.h"
#include "fstream.h"
#include "stdafx.h"
Put iostream.h and fstream.h inside angle-brackets <>. What's in stdafx.h? You shouldn't need it since you're not using MFC.
Try if(out.fail()).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 19th, 2001, 11:54 AM
#3
Frenzied Member
Where are the errors?
Usually you use angled brackets for headers like that, and quote headers for headers you make yourself. It makes a difference to the order in which paths are searched for header files. Maybe that's making it go wrong. It's easier to diagnose problems when you have error messages.
Harry.
"From one thing, know ten thousand things."
-
May 19th, 2001, 11:54 AM
#4
Frenzied Member
Ah well okay Parksie already posted
Harry.
"From one thing, know ten thousand things."
-
May 19th, 2001, 11:56 AM
#5
Monday Morning Lunatic
Originally posted by HarryW
Ah well okay Parksie already posted
Hehe sorry
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 19th, 2001, 11:57 AM
#6
Frenzied Member
You realise I'll never forgive you for this. I'm just devastated.
Harry.
"From one thing, know ten thousand things."
-
May 19th, 2001, 11:58 AM
#7
Monday Morning Lunatic
Sure you are You'll just have to get me back for it some other time then
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 19th, 2001, 12:00 PM
#8
Thread Starter
Hyperactive Member
here are the errors theres still problems with it.
here are the headers.
#include <iostream.h>
#include <fstream.h>
mywinapp.cpp
C:\MATT\MVC++\MSDEV98\MyProjects\mywinapp\mywinapp.cpp(99) : error C2143: syntax error : missing ';' before '.'
C:\MATT\MVC++\MSDEV98\MyProjects\mywinapp\mywinapp.cpp(99) : error C2143: syntax error : missing ';' before '.'
C:\MATT\MVC++\MSDEV98\MyProjects\mywinapp\mywinapp.cpp(101) : error C2065: 'out' : undeclared identifier
C:\MATT\MVC++\MSDEV98\MyProjects\mywinapp\mywinapp.cpp(101) : error C2228: left of '.fail' must have class/struct/union type
C:\MATT\MVC++\MSDEV98\MyProjects\mywinapp\mywinapp.cpp(106) : error C2228: left of '.put' must have class/struct/union type
C:\MATT\MVC++\MSDEV98\MyProjects\mywinapp\mywinapp.cpp(108) : error C2228: left of '.close' must have class/struct/union type
Error executing cl.exe.
Matt 
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
|