![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| memory addresses | areef4u | High Level Programming | 0 | 08-04-2006 04:43 AM |
| Multibyte characters to ASCII | jerardfjay | Shell Programming and Scripting | 8 | 11-17-2005 11:45 PM |
| Hex characters of ascii file | budrito | HP-UX | 2 | 08-10-2005 07:26 PM |
| stupid question about ascii characters | jalburger | High Level Programming | 2 | 09-28-2004 12:56 PM |
| memory addresses | Paravozzz | High Level Programming | 0 | 10-15-2002 09:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
c language + simple question regarding memory addresses and ASCII characters
Just a simple question (which may seem silly so bear with me) that arose in my mind the other day. Do ASCII characters by themselves (e.g. /n, 0, a) have an actual memory address ?
My question arises, because Im aware that each time I create and initalise a pointer like this for example Code:
int *ptr = 5; many thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
|
|
#3
|
|||
|
|||
|
For the code I spoke of in my first post,
Code:
int *ptr=5; I tried this Code:
char *str="helloworld\n";
printf("string value is %s\n",*str)
As pointers are meant to be assigned to memory locations (and point to values), with respect to this basic understanding and the fact that ASCII characters have memory addresses, aren't both code segments technically correct ?? Last edited by JamesGoh; 01-24-2008 at 04:18 PM. |
|
#4
|
|||
|
|||
|
Code:
int *ptr=5; Code:
char *str="helloworld\n";
printf("string value is %s\n",*str)
Code:
printf("string value is %s\n", str);
Code:
printf("str points to %c\n", *str);
|
|
#5
|
|||
|
|||
|
So this is always the case (except for user-defined strings) in real world programming, even though individual ASCII characters (such as 5) have memory addresses ?
|
|
#6
|
|||
|
|||
|
Quote:
Code:
char v = '5'; |
|
#7
|
|||
|
|||
|
Shamrock, another question do individual integers, f. point numbers and doubles have mem. addressess as well ?
thanks for your help |
|||
| Google The UNIX and Linux Forums |