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

int abc[]={1,2,3,4,5,6,7,8,9,10}; array behv

i want to knw abt the behavior of this array int abc[]={1,2,3,4,5,6,7,8,9,10}; ?


int abc[]={1,2,3,4,5,6,7,8,9,10};

for (int i=0; i< 10 ; ++i){

cout<<*abc;
abc++; // why is this thing not working ??


}
cout<<*abc<<endl;
Aug 29 '12 #1
5 2440
johny10151981
1,059 1GB
You will have to understand the behave of pointer.
when you define like this
Expand|Select|Wrap|Line Numbers
  1. int abc[]={1,2,3,4,5,6,7,8,9,10};
compiler creates an array name abc with length of 10 and set the value you put.

now its an array and also abc is a pointer. abc is pointing on some address.

so, if you print abc you will actually print the address of abc;

I will have to go, you better read about accessing pointer
Aug 29 '12 #2
you delare:
int abc[]={1,2,3,4,5,6,7,8,9,10};

after that, abc variable will become constant pointer point to the first element in this array and it means you can not change the value of it.

so operation:
abc++;

is impossible.
Aug 30 '12 #3
johny10151981
1,059 1GB
good catch. very important point. what compiler are you using?
Aug 30 '12 #4
i am using visual studio 2010.. sometimes codeblock .
Aug 30 '12 #5
@nextstep u explained this problem very beautifully .. thank u so much everyone ...
Aug 30 '12 #6

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

Similar topics

8
by: Michelle | last post by:
hi, i have created an array from recordset containing user names eg. (davidp, davidp, evenf, patricka, rebeccah) which i have sorted in alphabetical order, but i need to identify duplicates...
26
by: Peter Olcott | last post by:
// // Is there something wrong with my syntax for the // Copy Constructor of an Array Element, or does // the C++ language not support this? // #include <stdio.h> #include <stdlib.h> ...
7
by: Frank M. | last post by:
I'm trying to declare an array of pointers to structures so that I can make the last element a NULL pointer. I figure that it would more easily allow my library routines to know when to stop...
2
by: | last post by:
Hi All, How can I create an array of functionsand how would I call them many thanks
9
by: Steve | last post by:
Hello, I created a structure ABC and an array of type ABC Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure Public ABC1 As New ABC, ABC2 As New ABC
4
by: Rajesh Shukla | last post by:
Array type object of a class is declared like abc a=new abc(); but how to call methods
0
by: ARYAK | last post by:
Hi, I am trying to write a program which reads an array of string from a text file. The text file looks like : " array txt :: " ASDESRHTEETHAEHHAHTAERHARHAR" With the program below, I want to...
2
dlite922
by: dlite922 | last post by:
difficult to explain, easier to show: Here's what my data looks like on the PHP side: Array ( => Array ( => 20003001 => ABC RESTAURANT
5
by: Sunny | last post by:
Hi, Do anyone, Knows, How to get array Name? Like If I have a array: abc & I would like to get the name abc, How can I do that. I am trying to set abc.name but its not working. I have to...
2
by: winzone | last post by:
Last time interview, I got this questions for test. I would like to know which answer is correct. Q: Assume you have a list "ABC" which contains structures of "XYZ". "ABC" has 10 "XYZ" objects...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...

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.