473,322 Members | 1,714 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,322 software developers and data experts.

C++ Array importing int's from .dat and reverse out to screen

I know this code is wrong, and I am paying the price now for focusing on Linear last semester during the first half of C++, but I am trying to figure this out. Can anyone help? I want to make sure:
1. I am importing the file externally
2. Why this doesn't work with the variables I have chosen.

const int MAX = 10;

int main ()
{
int numbers[MAX]; //variable that stores the integers
ifstream inData; //enables istream
int value;
int index;

inData.open("reverse.dat");
for (index = 0; index < MAX; index++)
{

inData >> value[index];
numbers = value[index];
}

for (index = MAX - 1; index >= 0; index--)
cout << numbers[index];
return 0;
}

Error codes:
M:\C++\Labs\lab12\lab12\reverse.cpp(21) : error C2109: subscript requires array or pointer type
M:\C++\Labs\lab12\lab12\reverse.cpp(21) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
M:\C++\Labs\lab12\lab12\reverse.cpp(23) : error C2109: subscript requires array or pointer type
M:\C++\Labs\lab12\lab12\reverse.cpp(23) : error C2440: '=' : cannot convert from 'int' to 'int [10]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
Mar 23 '07 #1
1 1846
dmjpro
2,476 2GB
value[index] check this line ..... u declare this as normal varibale but not as an array .....
Mar 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Fabian Wauthier | last post by:
Hi list, I am trying to dynamically grow a 2 dimensional array (Atom ***Screen) of pointers to a struct Atom (i.e. the head of a linked list). I am not sure if this is the right way to do it: ...
2
by: Bryan | last post by:
Apologies if this is a noob question, but I've been struggling with this for quite a while... I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string...
8
by: ulyses | last post by:
I'm trying to put pointer to flexible array of structures in other structure. I want to have pointer to array of pixels in screen structure. Here is mine code, but I think it isn't quite all right:...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
8
by: arnuld | last post by:
i have created a solutions myself. it compiles without any trouble and runs but it prints some strange characters. i am not able to find where is the trouble. ...
4
by: Tarique | last post by:
/** A palindrome is a number that is the same whether it is read from left-to-right or right-to-left. For example, 121 and 34543 are both palindromes. It turns out that nearly every integer can be...
7
by: Alenik1989 | last post by:
i have this code which suppose to get a n input from the file and store it in a char array then i have to inverse it..... rhis code isnt complete but im getting a wiered error i see the error ...
6
by: MN | last post by:
I have 2 questions: 1- Why isn't possible to declare a static char array inside function ? the compiler gives this error: storage size of ‘array’ isn’t constant. 2- Why isn't possible to...
2
by: raylopez99 | last post by:
Here is a short program demonstrating using IEnumberable, Linq, predicates, extension methods and some tricks and how to convert an IEnumberable sequence into an array. For future reference, not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.