LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 12-10-2005, 02:03 PM   #1
geodpsa
LQ Newbie
 
Registered: Nov 2005
Posts: 4

Rep: Reputation: 0
Question C++: Save a table of numbers from a file to an array


Hello

I am a very new user of C++, so this is probably strikingly obvious but I've been stuck with it for a while.. Any help would be very much appreciated.

My programme is eventually to read a table of numbers (spatial data exported from a GIS) and do some calculations based on that information. I'm stuck at the reading the table bit.

I was trying to save all the data on an array, I'm not even sure that's possible, but I've tried:

______________________________________________
#include <iostream>
#include <fstream>

//...

using namespace std;

//...

#define horizontal 163
#define vertical 195

int SPACE [horizontal] [vertical];

int map()
{
ifstream inmap;
inmap.open("datacommas.dat"); //open a .dat file where 163x195 datapoints are saved, separated by commas

inmap >> SPACE;

inmap.close();

return 0;
}

//...

int main()
{
map();
//...

return 0;
}
______________________________________________

To which the g++ compiler comments:

(line where inmap >> SPACE is): no match for `std::ifstream& >> int[163][195]' operator
/usr/include/c++/3.2.2/bits/istream.tcc:83: candidates are:
std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(std::basic_istream<_CharT,
_Traits>&(*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char,
_Traits = std::char_traits<char>]
/usr/include/c++/3.2.2/bits/istream.tcc:92:
std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT,
_Traits>:perator>>(std::basic_ios<_CharT,
_Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits
= std::char_traits<char>]
[and goes on for ages]


Thanks

Despina

Last edited by geodpsa; 12-10-2005 at 02:19 PM.
 
Old 12-10-2005, 03:55 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php

In this case I've closed the older one because the dupe was
in the more appropriate forum.

http://www.linuxquestions.org/questi...65#post1992565
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell scripting - Adding many numbers in an array Stingreen Linux - General 2 10-25-2004 05:25 PM
numbers as file owners stabu Linux - General 3 04-27-2004 12:29 PM
How to save routing table entries? drgowans Linux - Networking 6 09-23-2003 02:35 PM
Checking a file for numbers chrisk5527 Linux - General 1 09-12-2003 08:50 AM
file version numbers tjones11 Programming 2 03-15-2002 12:51 PM


All times are GMT -5. The time now is 09:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration