473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Probably me being stupid - fstream

I'm new to C++ and have been chucked in at the deep-end.

I have a C++ console app that works fine. All I want to do is write
to file however as soon as I include the fstream library and try to
compile VS .net chucks out errors, lots of them:

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(17) : error C2143: syntax error : missing '{'
before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(17) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(17) : error C2143: syntax error : missing '{'
before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(17) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(17) : error C2143: syntax error : missing '{'
before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(17) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(18) : error C2143: syntax error : missing '{'
before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(18) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(18) : error C2143: syntax error : missing '{'
before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(18) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(18) : error C2143: syntax error : missing '{'
before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdio(18) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio
. . .
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(19) : error C2143: syntax error : missing
'{' before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(19) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(19) : error C2143: syntax error : missing
'{' before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(19) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(19) : error C2143: syntax error : missing
'{' before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(19) : error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(20) : error C2143: syntax error : missing
'{' before ':'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\cstdlib(20) : fatal error C1003: error count exceeds
100; stopping compilation

I included fstream not fstream.h and also set using namspace std;
after finding some reference to it on these forums.

Any help would be greatly appreaciated

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 17 '05 #1
3 7084
> I'm new to C++ and have been chucked in at the deep-end.

I have a C++ console app that works fine. All I want to do is write
to file however as soon as I include the fstream library and try to
compile VS .net chucks out errors, lots of them:

Typical for C++ is that it generates tons of errors that have nothing to do
with it.
Try to remember when it compiled last time, and try to remember what you did
change, just before these errors.
If that doesn't solve then try to comment out parts of the code until it
starts compiling again.
This way you have some clue where to find the cause. The biggest chance is
that you have forgotten a ";" or used ":" instead of ";", or something else
very silly.

Another cause could be that your search path to the header files are
confused, and your are loading the wrong header file, or have multiple
header files with the same name but with different code. Try a "rebuild
sollution" instead of a normal compile.

Also typical for C++ is to include the header file multiple times, confusing
the compiler.
In your header try to use the "#pragma once" in front of your

example.h file
--------------
#pragma once
#include <string>
#include <saaa>
#include "nbbbbbb.h"
.....
--------------

I am afraid that it is going to be trial and error to find out what goes
wrong.
Nov 17 '05 #2
The problem seems to have been something to do with the program being
written in C, but using the TP switch on the command line to ensure
it's treated as C++ for windows environment.

As soon as I tried to reference fstream it weren't having any of it
and generated the errors in my previous post. I know this is
something to do with C/C++ and VS .net (2003) .

A bit of resaerch on the net suggested I try renaming the file to
.cpp. Brilliant! I managed to get the file to compile.

I attempt to build the file and am confronted with errors related to
std::xyz. I assume this is because I am using
namespace std;

Here is a sample:

[code:1:58affc7f54]Linking...
iscade_client.obj : error LNK2019: unresolved external symbol
"public: virtual __thiscall
std::ios_base::~ios_base(void)"
(??1ios_base@std@@UAE@XZ) referenced in function
"public: virtual __thiscall
std::basic_ios<char,struct
std::char_traits<char>
::~basic_ios<char,struct std::char_traits<char> >(void)"
(??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@X Z)
iscade_client.obj : error LNK2019: unresolved external symbol
"public: __thiscall
std::_Mutex::~_Mutex(void)"
(??1_Mutex@std@@QAE@XZ) referenced in function
"public: virtual __thiscall
std::basic_streambuf<char,struct
std::char_traits<char>::~basic_streambuf<char,struct

std::char_traits<char> >(void)"
(??1?$basic_streambuf@DU?$char_traits@D@std@@@std@ @UAE@XZ)
iscade_client.obj : error LNK2001: unresolved external symbol
"long const std::_BADOFF"
(?_BADOFF@std@@3JB)[/code:1:58affc7f54]

However if I take the fstream stuff out, voila it works perfectly.

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 17 '05 #3
Hi i fact i too faced the problem and was scrating my head for three days...
after comming to your solution i tried.so , one more thing is that , when you change the project setting to compile as C++ , that wont affect the files with .C files.

so , we need to change the individual files properties to /Tp switch..
its strange that , there is no clue or documented properly , probably , mistake is mine !
anyways cheers to this site for solving my problem !

Have a good Day !

From http://developmentnow.com/g/42_2004_...---fstream.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Apr 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Materialised | last post by:
Hi, could someone have a look at the following code and the error message below, and point out where my error is, as I am having trouble figuring where I am going wrong. #include <algorithm>...
3
by: harry | last post by:
Trying to get a function working in IE 5.5 (sp3) & Mozilla1.6 The function is called when a table row is double clicked i.e... function dblClicked() { getElement("viewSearch").click(); } ...
4
by: Steven Steyaert | last post by:
I hided a Query (via properties), how to unhide?? Is there another simple way to protect a query so that nobody can run it? Thx in advance Steven
1
by: Daisy | last post by:
error CS0117: 'System.Collections.ArrayList' does not contain a definition for 'Item' Only one answer in Google Groups, and I'm positive I'm using it correctly...! Posts is my ArrayList. I...
6
by: @sh | last post by:
I know this is probably a real simple one, but I'm obviously missing something.. I'm building a function that I'll use throughout a website in the situation that I have two text boxes - the two...
3
by: PT | last post by:
Hi, not sure if this is just me, an already known bug or what, but if anyone can shed light on why this does what it does it would be greatly appreciated, it seems to work as expected if you're...
1
by: Stef Mientki | last post by:
Does anyone know the equivalent of the MatLab "diff" function. The "diff" functions calculates the difference between 2 succeeding elements of an array. I need to detect (fast) the falling edge of...
4
by: LShelby | last post by:
I have already inserted information (a state's name, abbreviation, year of admission, etc) into a linked list (not shown). Now when I'm trying to find a state in the list, a state that the user...
17
by: tomaz | last post by:
hi I've been searching the net for a solution, but did not find it. I use following css code: checkbox: input.largerElement { width: 25px;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.