If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Here is the code. The program is supposed to input data from a file, do a couple simple calculations, then output it to another .txt file. Here is the code. This is my first post and am starting to get into computer programming so figured I should join a forum such as this one. Thanks for any help guys!!

Besides, you have to use Code tags to make your code snippets readable. Do you see the difference between your original code snippet and its good formatted variant when using code tags?
Please, read the Announcement: Before you post....

Re: Odd error from VS 2010 C++

Okay, you're coming off kind of aggressive...Or maybe I'm getting the wrong impression.
As I said, this is literally my first class in programming. I've never done it before. I just can't figure
out why I'm getting a syntax error from a .txt file. I am not doing anything to specifically compile
the .txt document. I just created it and added numbers to ifstream the data into the c++ document.
I spent about 10 hours today writing this code and really just want some help. Thank you.

Re: Odd error from VS 2010 C++

Originally Posted by antlet88

Okay, you're coming off kind of aggressive...

Maybe... But it was just because you had ignored what I told you in my first reply...

Originally Posted by antlet88

I just can't figure out why I'm getting a syntax error from a .txt file. I am not doing anything to specifically compile
the .txt document. I just created it and added numbers to ifstream the data into the c++ document.
I spent about 10 hours today writing this code and really just want some help. Thank you.

Re: Odd error from VS 2010 C++

c++ programs normaly have an extension of .cpp. What's the name of the program you are trying to compile? Data.txt seems to be a text file that is used by the program. Somehow VS seems to think it should compile this. It may be that's it's got part of the solution that VS is trying to compile. In VS you should have a Solution Explorer window. In this window you should see a tree of the solution you are trying to produce. Under the branch source files you should see the name of the program you are trying to compile. You should not see data.txt here. If you do, then remove it (but don't delete the file). You should also see branches for header files and resource files etc. gain, data.txt should not appear here. The code you supplied compiles without error so somehow the complier is trying to complile your data.txt file. If you can't see this file name in the soultion explorer, try looking in properties of the project. Somwhere you're told VS to treat data.txt as a source file.

Hope this helps but trying to work out an issue with the complier is sometimes harder than debugging code!

Re: Odd error from VS 2010 C++

Thanks everyone who didn't just yell at me for formatting. I'm sure once I become better at programming those things will come a little more natural. I'll try those recommendations tonight. Unfortunately I have several other classes I need to study. I'll try looking in the solution explorer for a file like that, and then make sure I open the files before I use them. Thanks for the tips. Really appreciate it.

Re: Odd error from VS 2010 C++

Originally Posted by antlet88

Thanks everyone who didn't just yell at me for formatting.

No one was yelling. From the point of view of folks trying to answer it can be a bit frustrating to try to wade through unformatted code and also respond to a post only to have the OP seem to ignore the response. If you want the maximum help from this forum, try to remember to respond to any questions from other posters - even if the question seems to be unrelated. Of course, not every response is going to be on the mark, but as you gain experience, you'll be able to distinguish what's relevant. Actually, as you gain experience, you'll be answering questions, not posting them.

In terms of your problem, open the solution explorer, right click on the txt file in question, and choose properties. Make sure that the text file is set to be excluded from the build. I'm using VC++ 2012 and I see 3 settings: "Excluded from Build", "Content", "Item Type". In my project, only "Item Type" has a value ('Text'). Earlier versions of VC, might have some settings worded differently.

Re: Odd error from VS 2010 C++

Hey it worked. I found the setting exclude from project and it builds just fine. I mean the program doesn't actually work but at least it runs. Haha. I think the numbers from the text file aren't being streamed into the program properly because the calculations are all wrong. I fixed the issue with using the text file before I opened it. Oh well. I'll have to hand it in as is. Thanks for all of your help guys. Sorry about the formatting. I'll try and clean it up next time.