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
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
I always get a null pointer error.
many thanks
Yes they do. Your declaration creates a pointer but does not constrain it to a variable of type int. Does your code compile okay and on what compiler?
the compiler (I am using gcc btw), produced one warning saying that a pointer from integer was made without a necessary typecast. (shamrock warned me of this, so this gcc output was probably expected).
I tried this
and found the program compiled fine, but at runtime I got a segmentation fault error. I also found that in the first code segment, if you ignore the compiler warning and run the program straight, you get the same run-time error.
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 ??
Pointer can only be initialized to zero or null if it does not point to a variable of that type.
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 ?
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 ?
Yes ASCII characters have memory addresses though 5 is an integer not an ASCII character. To be intrepreted a character in C it needs to be in single quotes.
Hi,
I'm writing a BBS telnet program. I'm having issues with it not displaying lower ASCII characters. For example, instead of displaying the "smiley face" character (Ctrl-B), it displays ^B. Is this because i'm using Ncurses? If so, is there any way around this?
Thanks. (3 Replies)
Hi,
I have many text files which contain some non-ASCII characters. I attach the screenshots of one of the files for people to have a look at. The issue is even after issuing the non-ASCII removal commands one of the characters does not go away. The character that goes away is the black one with a... (2 Replies)
Hi,
I have a file having following content.
<sip:9376507346@97.208.31.7:51088
<sip:9907472291@97.208.31.7:51208
<sip:8103742422@97.208.31.7:51024
<sip:9579892841@97.208.31.7:51080
<sip:9370904222@97.208.31.7:51104
<sip:9327665215@97.208.31.7:51104
<sip:9098364262@97.208.31.7:51024... (2 Replies)
I am having a file(1234.txt) downloaded from windows server (in Ascii format).However when i ftp this file to Unix server and try to work with it..i am unable to do anything.When i try to open the file using vi editor the file opens in the following format ...
@
@
@
@
@
@
@
@... (4 Replies)
Hi gurus,
I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
you have three variables of type char, int and float in continous memory locations. How do you print the contents of each of these.???
Thanks in advance. (0 Replies)
Hello,
Is there any UNIX utility/command/executable that will convert mutlibyte characters to standard single byte ASCII characters in a given file?
and
Is there any UNIX utility/command/executable that will recognize multibyte characters in a given file name?
The typical multibyte... (8 Replies)
i know it's out there, but I cannot remember how to check if a given ascii character string contains all digits or not ... any ideas?
ie...function("123") --> OK
function("NOT_A_NUMBER") --> returns error
thanks!! (2 Replies)
where is addresses(what kind of memory) like this one "df605d50".
I want to print address of locan variable:
printf("&i - %p", &i);
and I have
&i - df605d50. (0 Replies)