Dear visitors and members, with the staff having moved on to other life interests and as a result of changes in people's internet usage habits, the CodeWalrus community have migrated almost entirely to Discord, IRC and WalrusIRC and is now essentially a place where to hang out, chat about gaming, programming, music, anime, and chill. As a result, even though the CW forums will remain open for posting, for faster TI, Casio or HP calculator help and news we recommend using the bilingual TI-Planet forums instead.

### WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

0 Members and 1 Guest are viewing this topic.

#### James Oldiges

• Full User
• Join Date: Jan 2015
• Location:
• Posts: 48
• Post Rating Ratio: +0/-1
« on: January 14, 2015, 02:11:23 pm »
Code: [Select]
`Int a [4]Int b[4]a[6] = 5`
OK, my professor heavily implied that will always result/be the same thing as b[1] =5.  Can anyone confirm this, as I'm 99% sure that it's not true...

Thanks!
« Last Edit: January 14, 2015, 02:13:45 pm by aeTIos »

#### Snektron

• Lvl 69 Russian Snake
• Super User
• Join Date: Dec 2014
• Location: Netherlands
• Posts: 3165
• Post Rating Ratio: +32/-0
• SSSssssss.....
• Gender:
« Reply #1 on: January 14, 2015, 02:36:48 pm »
I'm relatively new to C, but it's easy to test:

int a
[4];
int b[4];
a[6] = 5;
printf("%d",b[1]);

on my PC this results in "4201520" .
I suspect that this a compiler thing is though...
I'm using mingw, but if you have a compiler which
parses  int a[4 as "make a 4*4 bytes large datablock here",
it could work (I'm not really sure if some compilers work this way).
• Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...

#### matrefeytontias

• Full User
• Join Date: Nov 2014
• Location: France
• Posts: 200
• Post Rating Ratio: +5/-1
• Gender:
« Reply #2 on: January 14, 2015, 03:49:00 pm »
Even if it's true, don't do that. That's horrible.
• Calculators owned: TI-83+.fr, TI-Nspire CAS prototype, TI-84+ CSE, TI-Nspire CX
My TI games (some got their own article on non-calc websites !) : http://www.ticalc.org/archives/files/authors/112/11202.html

My moozik (100% free metal) : http://www.soundcloud.com/matrefeytontias

#### Snektron

• Lvl 69 Russian Snake
• Super User
• Join Date: Dec 2014
• Location: Netherlands
• Posts: 3165
• Post Rating Ratio: +32/-0
• SSSssssss.....
• Gender:
« Reply #3 on: January 14, 2015, 04:10:26 pm »
Yeah... He's probably not much better than my programming teacher...
• Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...

#### Duke "Tape" Eiyeron

• Urist McEiyolobster
• Super User
• Join Date: Nov 2014
• Location: (V)(-_(//));(V)
• Posts: 1636
• Post Rating Ratio: +11/-2
• Fanciest Walrus of the oceans.
• Gender:
« Reply #4 on: January 14, 2015, 05:56:56 pm »
I'm relatively new to C, but it's easy to test:

int a
[4];
int b[4];
a[6] = 5;
printf("%d",b[1]);

on my PC this results in "4201520" .
I suspect that this a compiler thing is though...
I'm using mingw, but if you have a compiler which
parses  int a[4 as "make a 4*4 bytes large datablock here",
it could work (I'm not really sure if some compilers work this way).

Actually, you can't really know what's happening. SOmetimes the compiler directly removes the variable as it's not used or their memory zones aren't adjacent all the time. Don't ever do that as Matref said, it's like a russian roulette (hello to the snake).
• Calculators owned: A lot.

#### James Oldiges

• Full User
• Join Date: Jan 2015
• Location:
• Posts: 48
• Post Rating Ratio: +0/-1
« Reply #5 on: January 14, 2015, 06:55:36 pm »
Alright, thanks.
I didn't think it would work, but I wasn't certain enough to correct the professor.

The class is...  interesting. He will have code exmples on the projector, but never has them run nor compiled.
« Last Edit: January 14, 2015, 06:58:48 pm by James Oldiges »

#### Snektron

• Lvl 69 Russian Snake
• Super User
• Join Date: Dec 2014
• Location: Netherlands
• Posts: 3165
• Post Rating Ratio: +32/-0
• SSSssssss.....
• Gender:
« Reply #6 on: January 14, 2015, 08:19:21 pm »
Mine's favourite language is python and thinks it can actually run faster than the
language it's written in. We ran a simple test vs java and java - even JAVA - can
beat it hands down (although this may be the interperter's fault). Anyway, he hates me
and my friend b/c we hate Python and inspects our projects thoroughly for any
mistakes while others get grades by just looking at their work.
• Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...

#### xlibman

• Omni founder & CW co-founder
• CodeWalrus Staff
• Super User
• Forum Maintenance
• Original 5
• CodeWalrus Supporter
• Join Date: Nov 2014
• Posts: 18973
• Post Rating Ratio: +100/-5
• Gender:
« Reply #7 on: January 14, 2015, 11:30:16 pm »
The class is...  interesting. He will have code exmples on the projector, but never has them run nor compiled.
I hate when I have a computer class and the teacher is less experienced than most of the classroom. >.< If  you ever need help, then you are in a bit of trouble. Is he really giving you code examples that don't always work?
• Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
• Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

#### JamesV

• Full User
• CodeWalrus Supporter
• Safe-haven access
• Join Date: Jan 2015
• Location: Australia
• Posts: 124
• Post Rating Ratio: +3/-0
• Gender:
« Reply #8 on: January 15, 2015, 12:05:06 am »
Like Eiyeron said, it might work, but that would just be pure luck. The variables will be assigned to wherever there is free memory - whether or not that happens to place them adjacent to each other (and with "a" preceding "b") is (essentially) random.

Not a good habit to get into

You can also use the following HTML or bulletin board code to share it on your page or forum signature!

Also do not forget to check our affiliates below.