Click to See Complete Forum and Search --> : File I/O HELP!


markwalker84
July 17th, 2006, 06:35 AM
Hi there.

Firstly:

I am using an XP machine running SP2.
I am using Microsoft Visual C++ 2005 Express Edition.
I am new to VC++ (have a base in C)
I click New -> Project -> CLR -> Windows Form Application
I use the template style files that VC++ gives me which include;

Form1.h
resource.h
stdafx.h
app.ico
app.rc
AssemblyInfo.cpp
"Project_Name".cpp
stdafx.cpp
ReadMe.txt

So - now that everyone knows where i am coming from hopefully i can ask a question more effectively :-)

I am trying to continually read in 3 lines from a text file.

Text.1
Number.1
Number.1
Text.2
Number.2
Number.2
(...)

and then store each to an array

Text[] - should this be String, std::string, char Text[][].......??????
num_1[]
num_2[]


So far all the code i have written has been added to Form1.h in the form of event handlers, and also a small .h file which contains my definitions of the arrays i want to store this text file information into (as well as a couple of other variables).

I would then like to be able to use those stored array values at a later date - for example; outting the text value to a label, or using the numerical value on a slide bar - just anything really.

I simply cannot work out how to do this :-( I have googled for about 2 full working days now and nothing seems to work. I have been trying fin >> & InFile >> with the appropriate #include etc but consistantly get errors along the lines of;

LNK4248: unresolved typeref token (0100004D) .....
LNK2020: unresolved token "int * _bristles"
LNK2021: unresolved external symbol "int * _bristles"

( this confuses me as the variable "_bristles" is defined in my added header file as "int _bristles[]" )

If anyone can spill any light on this issue whatso ever i would be eternally grateful!


All the best


Mark

cilu
July 18th, 2006, 04:42 AM
and then store each to an array

Text[] - should this be String, std::string, char Text[][].......??????
num_1[]
num_2[]

Depends how you read. If you use for instance STL streams to read it, you should use std::string. If you are using .NET streams use System::String.

As for the linking errors, you should post the code.

markwalker84
July 18th, 2006, 05:02 AM
Thanks for the reply,

When you say .NET streams and STL streams.... what exactly do you mean?

sorry if that is a very noobish question :-p

I have been trying to use the commands;

fin >> Text[xxx];

and

InFile >> Text[xxx];

But those have not worked (and i did include all the necessary file open / close etc commands - im 99% sure)


Thanks again


Mark

cilu
July 18th, 2006, 10:58 AM
.NET streams means the classes you find in the Syste.IO namespace (StreamReader/Writer, StringReader/Writer, TextReader/Writer, MemoryStream, etc. etc.)

STL streams mean strings from the std namespace from the C++ Standard Template Library (ifstream, ofstream, etc.).

Krishnaa
July 18th, 2006, 11:07 AM
LNK4248: unresolved typeref token (0100004D) .....
LNK2020: unresolved token "int * _bristles"
LNK2021: unresolved external symbol "int * _bristles"

( this confuses me as the variable "_bristles" is defined in my added header file as "int _bristles[]" )



How is is defined ? Can you post exact code ?

markwalker84
July 19th, 2006, 06:56 AM
Thanks for the help guys - i managed to get it fixed.

I forgot to define the size of my arrays... DOH!

Mark :)