I have recently started learning c and I am having some pro in understand the concepts of arrays & pointer can any one out the re help me with these areas thanks
I have recently started learning c and I am having some pro in understand the concepts of arrays & pointer can any one out the re help me with these areas thanks
[quote author=wings link=board=19;threadid=3438;start=0#msg31557 date=1080330516]
I have recently started learning c and I am having some pro in understand the concepts of arrays & pointer can any one out the re help me with these areas thanks
[/quote]
Can you be more specific? What is it about pointers and arrays that you don't understand? Are you doing a course, or are you trying to learn by yourself? Do you have a book about C? If so, which book do you have. If you don't then get one. Have you tried writing programs using arrays or pointers?
i agree, but what i have found to be super benefical also is web tuts, that are specific to the tasks you are trying to achieve.Do you have a book about C? If so, which book do you have. If you don't then get one.
[quote author=wings link=board=19;threadid=3438;start=0#msg31557 date=1080330516]
I have recently started learning c and I am having some pro in understand the concepts of arrays & pointer can any one out the re help me with these areas thanks
[/quote]
Arrays
An array is an ordered set of values denoted by an index. Think of it as a book with numbered pages. On page 1 you write something, lets say your name, and on page 2 you write something else, lets say your address. The array array now has a size of 2, i.e., it is currently storing 2 items. To reference the items stored in the array you use the index. So if you wanted to access youre name youd say "book[0]" (with most languages, the index of an array starts at 0) and to access your address you'd use "book[1]".
An array with an index will be treated the same way as a standard string or numerical variable.
So a number stored in an array is the same as a number anywhere else.
eg. All the code snippets below are equivalent:
1.
val = 4 + 3;
2.
tmp_var = 3;
val = 4 + tmp_var;
3.
num[2] = 3;
val = num[2] + 4;
There are also muti demntional arrays. Think of those in the same way you would an Excel spreadsheet. It has rows and columns and as such it uses two indices with raferencing data.
You'll have to do some reading from here on out.
Pointers
A pointer is a reference to an object. i.e. an object pointing to another object. This is a very powerful tool in the rhelm of data structures.
A data structure is (as the name suggests) a structure (object) used to store data. Usually lots of it.
One particular data structure in which pointers are useful is that of a Linked List. The idea behind a Linked List is that you can create a large data store by having an object store a set of information and then have the object point to an identical object that stores more data etc.
It's useful when you have data that you need to traverse (move from one record to the next) forwards and sometimes backwards (Doubly Linked List - this utalizes two pointes, one for the next object in the series and one for the previous).
e.g. If you had a list of students along with their address, telephone number, etc. You could store all that information of any particular student in an object that you create. In the same object you'd create a pointer. The type of the pointer will be the same as the object you are creating. It's a reflexive reference. So if your objects name is "Student" then the pointer you declare will also be of type "Student". This is simply because that's the kind of object that it's going to point to; another Student.
Next you would create multiple instances of your Student object, each time populating it with the information of a single student, and setting the pointer to point to the next object that you create, then populate that object with the information of another student, etc.
Any more questions? Ask.
anyone know any sites for tuts on C?
try www.cprogramming.com . that has some good c programming tutorials
The views expressed in the above post are not neccesarily the views of icuucme.
you really need to get a teacher or somebody to explain these concepts to you face to face, it might save you some time in getting started.
Check out My Awesome Blog & News Jamaica
yeah..it kinda hard learning C over the internet
The views expressed in the above post are not neccesarily the views of icuucme.
oh but thanks anyways
Wow Cknight that was a decent explanation for pointers n arrays.. i do computing @ UTECH an boy... C have me a ways.. but that wasnt bad at all...