Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

Pointers in C

Name: Anonymous 2013-06-25 17:59

Hey guys I'm having a little trouble with the following example

#include <stdio.h>
int main(void)
{
char s[] = "Melbourne City";
printf("%s\n", &s[2]);
return 0;
}

which prints "lbourne City" instead of the address of letter 'l'.
I do understand that the %s in the printf continues until a null terminator is hit, but not why &s[2] returns a character in the first place.
Thanks.

Name: Anonymous 2013-06-25 18:11

use %d

Name: Anonymous 2013-06-25 18:16

but not why &s[2] returns a character in the first place.
&
address of
Does that look like a character to you, idiot?

Name: Anonymous 2013-06-25 18:24

Then why is the output "lbourne City" and not a memory address?

>>2
I don't want to change the code, I want to understand it.

Name: Anonymous 2013-06-25 18:33

>>4
learn what printf format control modifiers do then

Name: Anonymous 2013-06-25 18:37

>>5
stfu egwing faget, the program must print address. not the string

Name: Anonymous 2013-06-25 18:39

>>6
go to troll somewhere else

Name: Anonymous 2013-06-25 18:40

>>7
egin lel, saging faggot. just go try it on gcc. end of discussion

Name: Anonymous 2013-06-25 18:41

lel?

Name: Anonymous 2013-06-25 18:42

>>9
groski lel eggwing

Name: Anonymous 2013-06-25 18:42

btw check muh dubz

Name: Anonymous 2013-06-25 18:47

If you want to display the address of s[2], use the pointer specifier %p or arithmetic specifiers like %d, %i etc. The %s specifier takes a pointer and interprets the byte sequence found as ascii until NUL is encountered, which displays the string starting with the character at s[2].

Name: Anonymous 2013-06-25 19:01

>>12
>%s specifier takes a pointer
And "s" returns the address of the first letter, rather than the array itself?
I come from java.

Name: Anonymous 2013-06-25 19:22

>>13
&s[2] is the same as s+2 btw
you give the pointer to the third letter to %s which begins to read the string from it and to the end
are you dumb or what, pls go already

Name: Anonymous 2013-06-25 19:24

>>13
Pretty much, yes. The name of the array (in this case, s) is considered to be of pointer type in most contexts, thus evaluating to the address of the array's first element (in this case, a char with the value of 0x4D, meaning the letter 'M' when interpreted as ASCII).

If you want to display a string sitting in a char array, you use the specifier %s in the formatting literal, and just the array name as the following argument (the %s specifier, as mentioned, needs a pointer type to parse, and a name of an array happens to be treated as a pointer in this context, so no & operator is used). If you want to display just a part of the string, you use pointer arithmetic to point to the desired character, either like this

printf("%s", s + n); // n is the index of the starting char

or like this

printf("%s", &s[n]); // this is really just syntactic sugar for the above

If you want to see the address of a particular array element, you need to use specifers that show you a number, i.e. %d, %i etc. or %p (for the latter one you're best off casting the address to (void *), like this:

printf("%p", (void *)&s[n]);

If you're coming from java, pointers are a new concept to you - I recommend this as a solid introduction:

http://pweb.netcom.com/~tjensen/ptr/

It's especially important to understand what pointers and arrays have in common and what the differences are.

Name: Anonymous 2013-06-25 19:36

An example of when an array name is NOT considered to be of pointer type is when using the sizeof operator:

int main(void)
{
char arr[]="foobar";
printf("%d", sizeof(arr));
return 0;
}

will output

7

as the array has been initialized with 7 char elements (6 lowercase letters + a terminating '\0').

Name: Anonymous 2013-06-25 20:06

               `
>2013
>helping him

Name: Anonymous 2013-06-25 20:49

This thread is fucking shit.

Name: !!YtwzkeoLMFQUgZv 2013-06-25 21:30

I summon zombie L. A. Calculus for the rescue. Hail Satan!

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-26 3:09

>>19
U GOT UR FUCKING WISH YA RETOID

>>1
I'LL NULL TERMINATE U YA FUCKING RETOID.

>>2,12
WAT KINDA RETOIDED C IMPLEMENTATION ARE U USIN WHERE 'char *'S HAVE DA SAME REPRESENTATION AS 'int'S? GET OUT OF HERE, YA FUCKIN STACK BOI. YAINT RED DA STANDARD, YA DONT KNO C, AND YAINT EVEN RED DA DOCUMENTATION FOR printf.

>>16
SEE ABOVE AND REPLACE 'char *' WITH 'size_t', YA FUCKING RETOID.

>>4
Then why is the output "lbourne City" and not a memory address?

BECAUSE YAINT RED DA FUCKING STANDARD. DATS Y. SECTION 7.21.6.1 (fprintf) PART 7.

IF YAINT GOT DA STANDARD, AT LEAST TYPE 'man 3 printf', LOOK UP DA CONVERSION SPECIFIER SECTION, AND REED ABOUT 's'.

>>13
I come from java.
NO WONDER UR A COMPLETE RETOID.

>>15
AT LEAST DIS GUY SEEMS TO HAVE SOME IDEA OF WAT HE'S TALKIN' ABOUT. EXCEPT FOR DIS SHIT:

formatting literal
WAT DA FUCK IS DAT? AIN'T GOTTA BE A STRING LITERAL, IF DATS WAT UR THINKIN'.

If you want to see the address of a particular array element, you need to use specifers that show you a number, i.e. %d, %i etc. or %p (for the latter one you're best off casting the address to (void *)
YEA, UR NOTES ON %p ARE GOOD. EXPECTS A FUCKING 'void *' (ALTHOUGH 'char *' WILL HAVE DA SAME INTERNAL REPRESENTATION AS 'void *', SO IT DON'T MATTER SO MUCH IN DIS SITUATION)

BUT UR SUGGESTION OF %d AND %i MAKE U LOOK LIKE A RETOIDED STACK BOI WHO AINT RED DA FUCKIN STANDARD.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-06-26 3:47

WAT KINDA RETOIDED C IMPLEMENTATION ARE U USIN WHERE 'char *'S HAVE DA SAME REPRESENTATION AS 'int'S?
Just about every 32/32 system ever...

Name: Anonymous 2013-06-26 4:14

>>21
Yeah... if you really want to be pedantic, you may go ahead and cast an address to (int) to printf it via %i or %d - still, (sizeof(int) == sizeof(void *)), so it will work anyway, showing the address in decimal (while %p will show it in hex).

Also, size_t is a datatype for sizes proposed by ANSI C, but it's not really necessary to use it afaik.

Name: Anonymous 2013-06-26 4:20

>>12,14,15
You helped him!

>>22
still, (sizeof(int) == sizeof(void *))

I32LP64 master race wants to stomp your face

Name: Anonymous 2013-06-26 4:31

>>23
Notice that this was in reference to >>21 , where the assumption of both int size and pointer size of 4 had been made (32-bit int/32-bit mem map).

Name: Anonymous 2013-06-26 4:43

You faggots, I can't believe nobody has posted this yet.

#if __STDC_VERSION__ >= 199901L
#  define N sizeof pointer
#else
#  define N 4
#endif

void print_pointer(void *pointer)
{
    static char _[N];
    int i;
    for(i = 0; i < N; i++)
        i[_] = i[(unsigned char *)pointer];
    printf("%.*s\n", (int)N, pointer)
}

Why torture a man who simply asks for help? As if you've never been in the vulnerable position of asking for help!

>>1 This is the best way to print a pointer. Have fun buddy.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-26 5:24

>>21
WELCOME, LORD OF DA STACK BOIZ.

>>22
AHAHAH. AND WAT IF int ISN'T ABLE TO REPRESENT DA CONVERTED VALUE, U FUCKING RETOID?

U STACK BOYS AINT GONNA UNDERSTAND C SO LONG AS U THINK IT HAS A FUCKING CALL STACK.

Also, size_t is a datatype for sizes proposed by ANSI C, but it's not really necessary to use it afaik.
R U FUCKING SERIOUS? U JUST USED IT IN UR POST, U RETOID. sizeof GIVES size_t VALUES.

while %p will show it in hex
DIS TAKES DA FUCKING STACK BOY AWARD.

The argument shall be a pointer to void. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner.

>>25
WAT DA FUCK R U DOING?

Name: L. A. Calculus 2013-06-26 5:37

>>25
void print_pointer(const void *ptr)
{
    size_t i;

    fputs("0x", stdout);
    for (i = 0; i < sizeof ptr; i++)
        printf("%02x", ((unsigned char *) &ptr)[i]);
    puts("");
}


WHETHER DIS IS GOOD OR NOT DEPENDS ON DA FUCKING C IMPLEMENTATION. ALL DIS DOES IS PRINT OUT DA INTERNAL REPRESENTATION OF DA POINTER IN SEX YA DECIMAL. DAT CUD REPRESENT A NULL POINTER AS A NAKED DONKEY FOR ALL THE STANDARD CARES.

Name: Anonymous 2013-06-26 6:27

check 'em

Name: Anonymous 2013-06-26 6:32

Confusing the processes of printing a representation of the data pointed to by a pointer and printing a representation of said pointer like 1-san did is Terrible! and makes me very sad indeed.

Name: Anonymous 2013-06-26 6:53

>>27
Yours all wrongs.

void print_pointah(const char* z)
{
    intptr_t x = 0;
    for(;z;z--,x++);
    printf("%d", x);
}


This is the way of tree /prog/rider

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-26 7:19

>>30
TELL ME U ARENT FUCKIN SERIOUS. DATS DA STUPIDEST THING I'VE EVER SEEN.

Name: Anonymous 2013-06-26 7:33

I ABSOLUTELY LOVE CALCULUS GUY. IM GOING TO READ ALL OF HIS POSTS 5 TIMES. PLEASE KEEP POSTING.

Name: Lambda A. Calculus !!wKyoNUUHDOmjW7I 2013-06-26 7:37

>>32
UR NEW HERE ARENT YA, YA FUCKIN RETOID?

Name: Anonymous 2013-06-26 7:44

You guys all make valid points about >>1-san's problems, but the real one is
Melbourne
Melbourne is a terrible place.  Terrible!  I hope I never have to go back.

Name: Anonymous 2013-06-26 7:57

>>33
NO. I NEVER NOTICED YOUR PRESENCE UNTIL TODAY. I MUST APOLOGIZE. PLEASE TEACH ME MORE!

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-06-26 8:16

I32LP64 master race wants to eat all your memory
FTFY

If you want to go big, go ILP64. On a supercomputer with several TB of RAM.

Name: Anonymous 2013-06-26 8:28

>>36
Everything is absolutely disgusting in you, Cudder. Ew!

Name: Anonymous 2013-06-27 13:27

Soooo... if we assume an ILP32 system, what is inherently wrong about

printf("%u", &a);

given that it just works fine, and you know it will give decimal output? Why bother with

printf("%u", (int)&a);

if it does not really make a difference, or

printf("%p", (void *)&a);

which may or may not give decimal output (and tends to mostly give hex output)?

Calculus Guy 'RETOID' type rants welcome.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-27 14:01

>>38
what is inherently wrong about ...
DA FACT DAT UR MAKING DAT ASSUMPTION, YA FUCKING RETOID. UR PRETENDING A 'char *' IS AN 'unsigned int'. DIS AIN'T ABOUT DA FUCKING SYSTEM EITHER. U CUD WRITE A COMPILER/INTERPRETER/WATEVER ON SUCH A SYSTEM AND REPRESENT 'char *' HOWEVER U FUCKING WANT SO LONG AS IT'S COMPLIANT WITH DA STANDARD.

SO SHOVE IT UP UR ASS, STACK BOY. DA GROWN UPS ARE TALKING ABOUT C. GO BITCH ABOUT UR FAVOURITE C COMPILER SOMEWHERE ELSE, YA FUCKING RETOID.

(and tends to mostly give hex output)
AND WAT STATISTIC ARE YA BASING DAT ON, YA FUCKIN DEESH BAG?

YAINT DA KIND TO HAVE USED C LIBRARIES AND ARCHITECTURES IN UR TIME, SO WAT MAKES U THINK U KNOW SHIT, YA FUCKING STACK BOY? U THINK DA LISP MACHINE IS GONNA REPRESENT A POINTER AS A FUCKING SEX YA DECIMAL NUMBER? ITS POINTERS AIN'T EVEN NUMERS. NOW GET DA FUCK OUTTA HERE.

>>35
CHECK subject.txt IF U REALLY WANNA LEARN SHIT

Name: Anonymous 2013-06-27 14:04

>>39
DIFFERENT C LIBRARIES AND ARCHITECTURES*

Name: Anonymous 2013-06-27 14:06

>>40
What makes you so wise, calculus? Other than reading the fucking standard of course.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-27 14:15

>>41
I WATCHED DEANIS RICKY DEVELOP C. I WATCHED HIM WRITE IN C. I WATCHED A BUNCH OF MEDDLING HYENAS DESTROY C. AND I SURE AS FUCK WATCHED DEANIS RICKY KILL HIMSELF BECAUSE OF DOSE VERY SAME FUCKING HYENAS.

DATS WAT MAKES ME WISE, YA FUCKIN RETOID. I SAW C GROW. I SAW IT WHEN IT WAS PURE AND IN ITS PRIME. AND I SAW IT BECOME DA TAINTED MESS DAT IT IS TODAY. JUST LIKE FUCKING RICKY, EXCEPT I DIDN'T GO AND KILL MYSELF OVER IT.

AND I NOT ONLY RED DA FUCKING STANDARD. HERE, TAKE DIS, MIGHT FUCKIN TEACH YA SOMETHING: http://dis.4chan.org/read/prog/1369512114

Name: Anonymous 2013-06-27 14:18

>>39
Take your all caps ebonics back to Twitter, you fucking nigger.

Name: Lambda Arthur Calculus !!wKyoNUUHDOmjW7I 2013-06-27 14:21

>>43
*POINTS TO DA DOOR*
OUTTA MY THRED, RETOID.

Name: Anonymous 2013-06-27 14:26

>>39
>ITS POINTERS AIN'T EVEN NUMERS.

010010010110111001110100011001010111001001101110011000010110110001101100011110010010000001101001011101000010011101110011001000000110000101101100011011000010000001101110011101010110110101100010011001010111001001110011001000000010110100100000011000010110110001101100001000000110010101101100011100110110010100100000011010010111001100100000011100110111010101100010011010100110010101100011011101000110100101110110011001010010000001100001011011100110010000100000011000010010000001101101011000010111010001110100011001010111001000100000011011110110011000100000011010010110111001110100011001010111001001110000011100100110010101110100011000010111010001101001011011110110111000101110

Name: Anonymous 2013-06-27 14:26

Name: Lambda A. Calculus !!wKyoNUUHDOmjW7I 2013-06-27 14:34

>>45,46
SHOVE IT UP UR ASSES BEFORE I DO.

Name: Anonymous 2013-06-27 14:41

>>47
Do what? Shove it up your ass? Feel free, nigger faggot.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-27 14:43

>>48
HAHA, SURE, SINCE UR ASS IS MINE. *TAKES A SHIT ON DA STANDARD THEN SHOVES IT UP UR ASS* HOW DO U LIKE DAT, YA QUEER DEESH BAG? NOW REED IT, YA FUCKING STACK BOY.

Name: Anonymous 2013-06-27 14:46

>>42
I thought such manner of articulation didn't exist 40 years ago, especially not at high-grade establishments such as Bell Labs.

As far as "meddling" and "destroying" C is concerned, I understand you're referring to post-ANSI C standards, such as C90, C99, C11 etc. Not that they gained that much popularity anyway, ANSI C is still considered the "solid" standard by most. Unless you are a die-hard fan of oldschool vanilla K&R C.

Name: Anonymous 2013-06-27 14:51

Unix/C/C++ is the new eternal Jew. Unix/C/C++ is kike-ugly and yet, like virus, it gets everywhere, it perverts everything and everyone starts adoring and respect this ugly parasite. I can't imagine more filthy and Jewish software than Unix/C/C++.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-27 14:54

>>50
I understand you're referring to post-ANSI C standards, such as C90, C99, C11 etc.
UR DED RONG ABOUT DAT. FIRSTLY, ALL DOSE STANDARDS HAVE BEEN ADOPTED BY ANSI. DA ONLY DIFFERENCE IS DAT ANSI DIDNT FUCKIN PUBLISH 'EM. AND C89'S SHIT IN ITS OWN WAYS. MY FAVOURITE C'S A C DAT HAS NO FUCKIN NAME.

Name: Anonymous 2013-06-27 16:09

>A C DAT HAS NO FUCKIN NAME

DAT STANDARD ;)

Name: Anonymous 2013-06-27 16:16

>>38
Soooo... if we assume an ILP32 system, what is inherently wrong about
printf("%u", &a);

It's undefined behavior. For an example, consider a CPU with separate data and address registers (e.g. M68k). Your printf call would receive the pointer in register A1 (assuming the pointer to the format string is in A0), but the %u specifier tells printf to read from the data registers, in this case D0. That's only one of the ways it could fail even when int and void * are the same size. Even if it ``works on my machine'' there's no guarantee that different optimization settings or compiler versions won't break it.
$ tcc -run -
#include <stdio.h>
int main(void){printf("%d %f\n", 3.0, 10);}
10 3.000000

That's also presumably why this prints what it does on my machine.

Name: Anonymous 2013-06-27 16:24

>>52

so, you seem to have worked with dennis. would you mind if i use c++ just for its classes, using ansi c beyond ?

Name: Anonymous 2013-06-27 17:20

>>53
le back to /g/ meme spouting emote kid

Name: Anonymous 2013-06-27 19:43

Good ole /prog/. Can't even do understand basic pointers.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-27 23:56

>>55
I DON'T GIVE A FUCK ABOUT WAT I USE, SO LONG AS YAINT TALKIN LIKE A FUCKIN STACK BOY.

Name: Anonymous 2013-06-27 23:57

>>58
WAT U USE*

Name: Anonymous 2013-06-28 0:16

>>58
"stack boys" are... stackoverflow frequenters...?

Name: Anonymous 2013-06-28 1:05

>>60
``Stack Boy'' is actually a euphemism for a sex-crazed male, because they feel a need to push and then pop.  Needless to say, upon achieving Satori, a former stack boy realizes that direct memory address is far superior.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-28 1:25

>>60
Stack boy: Some retoid who believes that the C language has a call stack. This belief is a result of confusing the language with the implementation of the language.

Name: Anonymous 2013-06-28 2:17

>>62
Wow... L.A. Calculus spoke in non-caps.

Name: Anonymous 2013-06-28 2:23

>>63
koz he iz not him

now tell me L.A, Is it bad to define many extern, global variables ?

Name: Anonymous 2013-06-28 4:46

>>55
Use LISP for all your object/class/whatever the fuck else kind of fuckery.

Name: Anonymous 2013-06-28 6:49

>>65
But it's an unusable old hack. It's not even a language.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-28 7:24

>>64
C DONT HAVE GLOBAL VARIABLES YA RETOID.

Name: Anonymous 2013-06-28 7:27

>>67
EXTERNALLY LINKED OBJECT

Name: Anonymous 2013-06-28 7:27

>>67

it sure has. look :

#include <stdio.h>

extern int lel = 5; // global

void main() {
   printf("%d",lel);
}

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-28 8:30

>>69
OOH, U FUCKED UP BIG TIME YA RETOID.

extern int lel = 5; // global
DIS IS STRICTLY A FUCKIN DECLARATION. IT DOESN'T DEFINE AN OBJECT AT ALL, YA RETOID. YAINT RED DA FUCKIN STANDARD, AND YAINT KNO HOW TO USE extern.

void main()
NON-STANDARD RETURN TYPE.

printf("%d",lel);
NO TERMINATING NEWLINE LINE EMITTED TO stdout.

Name: Anonymous 2013-06-28 9:03

>>70

well, retoid. just tell me :

extern lel_t lel = new lel_t;

where is your DA STANDARD now ?

Name: Anonymous 2013-06-28 11:04

>>71
I wrote this poem for you:
If you think sepples is C, you should go back to /g/.
How do you like it?

Name: Anonymous 2013-06-28 12:08

Wipe my ass with hundred-dollar bills and laugh at the /g/.
-- Slaine, "Creed of the greedier".

Name: Anonymous 2013-06-28 12:14

Name: Anonymous 2013-06-28 13:09

Just let the retards who think sepples is C continue, it makes them easier to recognize as being retarded.

Name: Anonymous 2013-06-28 13:58

Global variables do exist in C, they're simply declared/defined (and optionally initialized) outside of any function and are accessible via their identifier to any function called in that source file. The 'extern' keyword, as hinted at above, does not define such a variable, it merely declares it (kind of like withe a function prototype versus a function definition); that variable must be defined in another source file which is to be linked.


#include <stdio.h>

void func1(void);    //func1 function prototype (i.e. declaration)
void func2(void);    //func2 function prototype (i.e. declaration)

int var = 5;        //global int variable decl., def. & init.
char arr[] = "foobar";    //global array of char decl., def. & init.

int main(void)         //main function (no prototype necessary)
{
    printf("\nvar and arr invoked by id from main():\n");
    printf("\tvar: %u\n", var);
    printf("\tarr: %s\n", arr);
    printf("\tsizeof(arr): %u\n", (int)sizeof(arr));
   
    func1();              //call to another function invoking global objects
    func2();              //call to yet another function invoking global objects
   
    return(0);           //program exit
}
   
void func1(void)       //func1 function definition 
{
    printf("\nvar and arr invoked by id from func1():\n");
    printf("\tvar: %u\n", var);
    printf("\tarr: %s\n", arr);
    printf("\tsizeof(arr): %u\n", (int)sizeof(arr));
}

void func2(void)       //func2 function definition
{
    printf("\nvar and arr invoked by id from func2():\n");
    printf("\tvar: %u\n", var);
    printf("\tarr: %s\n", arr);
    printf("\tsizeof(arr): %u\n", (int)sizeof(arr));
}


In the above program, var is a global variable called by id from main() as well as from two other functions; arr is an array seen as such (i.e. not decaying to a mere pointer, as evidenced by its sizeof evaluations) from any of the functions.

Global objects are about as "harmful" as the goto statement - generally not recommended to use on a regular basis, though can be useful in particular situations if used wisely.

Name: Anonymous 2013-06-28 16:05

>>76
Somewhat informative for a beginner... you must be new here! Are you Cudder?

printf("\tvar: %u\n", var);
printf("\tsizeof(arr): %u\n", (int)sizeof(arr));
Why %u instead of %d when the argument is of int type?

Name: Anonymous 2013-06-28 16:32

>>77
>Why %u instead of %d when the argument is of int type?

>printf("\tvar: %u\n", var);
Stricly speaking, it should be %i (or %d, %x or %o to force a specific number base for the output). Still, it makes no difference here really, as var is assigned a positive value anyway (the storage format is the same for int and unsigned int, it merely depends on the interpretation whether the contents are considered unsigned or two's complement signed).

>printf("\tsizeof(arr): %u\n", (int)sizeof(arr));
Here, you definitely want an unsigned value, as a negative sizeof return value would not make much sense. Again, as the size of the array is merely 7, it does not make an actual difference. If on a 16-bit-integer system you had an array larger than 32k (or on a 32-bit-integer system an array larger than 2G), the expression (int)sizeof(arr) would return a negative value - however, the %u specifier in the string literal would recast it to unsigned int anyway. To be totally proper, the return value of sizeof should be cast from size_t to unsigned int in the first place:
 
printf("\tsizeof(arr): %u\n", (unsigned int)sizeof(arr));

>Are you Cudder?
I don't think so. Though, I already did happen to make some contributions to this rather amusing thread.

Name: Anonymous 2013-06-28 16:51

>>78
Here, you definitely want an unsigned value, as a negative sizeof return value would not make much sense. Again, as the size of the array is merely 7, it does not make an actual difference. If on a 16-bit-integer system you had an array larger than 32k (or on a 32-bit-integer system an array larger than 2G), the expression (int)sizeof(arr) would return a negative value - however, the %u specifier in the string literal would recast it to unsigned int anyway. To be totally proper, the return value of sizeof should be cast from size_t to unsigned int in the first place:

printf("\tsizeof(arr): %u\n", (unsigned int)sizeof(arr));

Then printf("\tsizeof(arr): %zu\n", sizeof(arr));

Name: Anonymous 2013-06-28 17:46

>>79
Ah yes, the ever-so-obscure %z specifier. There you go, no need to recast to a generic arithmetic type then.

Name: Lambda Arthur Calculus !!wKyoNUUHDOmjW7I 2013-06-28 20:15

>>72
I LIKE IT.

>>76
var is a global variable called by id from main()
DA IDENTIFIER var HAS FILE SCOPE AND EXTERNAL LINKAGE, AND DA OBJECT IT REFERS TO HAS STATIC STORAGE DURATION. AND IT'S REFERENCED, NOT CALLED, YA RETOID. EEEEEH EEEEEEEEH EEEEEEEEEH EEEEEEEEEEEEEEH! ASIDE FROM DAT IT SEEMS LIKE U'VE ACTUALLY RED DA FUCKIN STANDARD.

>>78
the storage format is the same for int and unsigned int, it merely depends on the interpretation whether the contents are considered unsigned or two's complement signed
UR RIGHT DAT A POSITIVE, SIGNED INTEGER WILL HAVE DA SAME REPRESENTATION OF AN UNSIGNED INTEGER WITH DA SAME SIZE, BUT DATS A PRETTY CRAPPY WAY 2 SAY IT. YAINT GUARANTEED TWO'S COMPLEMENT.

the expression (int)sizeof(arr) would return a negative value - however, the %u specifier in the string literal would recast it to unsigned int anyway.
NOW DATS A LOAD OF SHIT. IF 'sizeof arr' YIELDS A VALUE DAT CAN'T BE REPRESENTED BY int, DA RESULT WILL BE IMPLEMENTATION-DEFINED. UR CONFUSING signed->unsigned WITH unsigned->signed. DA RESULT OF DA FORMER IS DEFINED AND DA RESULT OF DA LATTER IS IMPLEMENTATION-DEFINED. FURTHERMORE, sizeof DON'T HAVE A FUCKIN RETURN VALUE YA RETOID.

Name: Anonymous 2013-06-28 22:32

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-29 3:11

>>82
WAT DA FUK IS UR PROBLEM? I DONT LOOK LIKE DAT GUY, I LOOK LIKE GUY STEELE, YA RETOID.

Name: Anonymous 2013-06-29 18:24

>>83
It's not about looks - the "Y U NO"-Guy depicted in that image is an embodiment of the frustration and anger with an individual or group neglecting to do something considered more or less essential in the given situation - in this case, neglecting to read da fuckin Standard.

Name: Anonymous 2013-06-29 20:37

>>84
LLELELLEL EGIN MEME ANALYSIS GRO

Name: Anonymous 2013-06-29 22:32

>>85
meme analysis triggered by meme comprehension fail

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-06-30 1:31

IMAGES R FOR DA WEAK, YA RETOID. U SHUD USE TEXT ONLY BECUZ DAT IS DA UNIVERSAL INTERFACE.

Name: Anonymous 2013-06-30 2:34

Name: Anonymous 2013-06-30 15:23

>>88
I will NOT dereference that pointer you provided there.

Name: Anonymous 2013-06-30 15:45

>>89
Just wait, it's a pointer to a pointer.

Name: Anonymous 2013-07-01 20:40

Name: Anonymous 2013-07-01 20:46

Name: Anonymous 2013-07-01 20:51

Name: Anonymous 2013-07-01 20:56

Name: Anonymous 2013-07-02 0:20

Name: Anonymous 2013-07-02 0:25

Name: Anonymous 2013-07-02 0:30

Name: Anonymous 2013-07-02 17:11

spambegone

Name: Anonymous 2013-07-02 17:11

spambegone

Name: Anonymous 2013-07-02 17:11

spambegone

Name: Anonymous 2013-07-02 17:11

spambegone

Name: Anonymous 2013-07-02 17:12

spambegone

Don't change these.
Name: Email:
Entire Thread Thread List