Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4

Author Topic: Don't Capitalize main()  (Read 5464 times)

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Don't Capitalize main()
« Reply #30 on: June 05, 2009, 08:58:08 am »

It's perfectly acceptable to capitalize main().....


If you have an uncapitalized version.


For fun, try using #define and about 5 diffrent main()s, and the #define swaps around capitalizations so MaIn becomes main, but mAIn becomes MAin and so on.

Bonus if you enter it into the ioccc and it "wins".
Except entrants are far beyone such simple tactics.

Try(at least in C)
int array[53];

then to access it, use
3[array]
Logged
Eh?
Eh!

Mohreb el Yasim

  • Bay Watcher
  • ♫♪♫♫♪♫♪♪♫♪
    • View Profile
Re: Don't Capitalize main()
« Reply #31 on: June 05, 2009, 12:44:28 pm »

actually the big problem is that there are capital letters ... if there won't be the world woud be much easier ... but the real thing wich made me sad is that in C i couldn't do this with an int variable:
nextValue++%=6;
it would be just so cool if i could (it is for boucling values, so it goes from 0-5 and rebegins ...)
Logged
Mohreb el Yasim


GENERATION 24:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experime

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Don't Capitalize main()
« Reply #32 on: June 05, 2009, 02:41:49 pm »

actually the big problem is that there are capital letters ... if there won't be the world woud be much easier ... but the real thing wich made me sad is that in C i couldn't do this with an int variable:
nextValue++%=6;
it would be just so cool if i could (it is for boucling values, so it goes from 0-5 and rebegins ...)
?
agreed on the capital letters thing. t'would make life easier. ;D

and that "bouncing values" thing is easy enough to do. you can't do it in one statement, true. wait, i think you can, wouldn't var = var++ % 6 work? anyway, it's not hard.
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: Don't Capitalize main()
« Reply #33 on: June 05, 2009, 03:15:04 pm »

Every single programming language in existence that is written for adults is case sensitive. Get used to it.
true.

And if you actually try to learn windows... it's the case sensitive nightmare :P
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Don't Capitalize main()
« Reply #34 on: June 05, 2009, 04:06:51 pm »

And if you actually try to learn windows... it's the case sensitive nightmare :P

 ??? ??? ??? The Windows filesystem isn't case sensitive. Linux (et al) is. I assume you're mean something else?
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Don't Capitalize main()
« Reply #35 on: June 05, 2009, 05:42:26 pm »

Probably windows.h?
Logged
Eh?
Eh!

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Don't Capitalize main()
« Reply #36 on: June 05, 2009, 06:03:54 pm »

actually the big problem is that there are capital letters ... if there won't be the world woud be much easier ... but the real thing wich made me sad is that in C i couldn't do this with an int variable:
nextValue++%=6;
it would be just so cool if i could (it is for boucling values, so it goes from 0-5 and rebegins ...)

I don't even get what you're trying to do? You're trying to set the modulo of (nextValue + 1) to 6? First of all, setting the modulo can't ever define the number because 6%5 = 1, but also 11%5 = 1, and secondly, you'd need to define a second variable for the modulo operator because it can't work with only one.

What you could do is:

nextValue = nextValue%6

If it's 0 or 6 (or 12 or 18...), it returns 0 and if it's between 1 and 5 or between 7 and 11 et cetera, it'll return the remainder of the division (in other words, 1 for 1, 7, 13 etc. 2 for 2, 8, 14 etc. and so on)

Adding in the ++ operator would only mess up things (It'd return 0 at 5, 11 etc and 1 at values of 0, 6, 12 etc)
« Last Edit: June 05, 2009, 06:17:23 pm by Virex »
Logged

chaoticag

  • Bay Watcher
  • All Natural Pengbean
    • View Profile
Re: Don't Capitalize main()
« Reply #37 on: June 05, 2009, 06:15:00 pm »

Don't forget to pull that lever again or you'll have a buffer overflow.
For some reason, I read that as butter.
Logged

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Don't Capitalize main()
« Reply #38 on: June 05, 2009, 08:12:17 pm »

Or does he mean
nextValue=(nextValue+1)%6?
or
nextValue=(nextValue%6)+1?
Logged
Eh?
Eh!

zchris13

  • Bay Watcher
  • YOU SPIN ME RIGHT ROUND~
    • View Profile
Re: Don't Capitalize main()
« Reply #39 on: June 05, 2009, 09:05:04 pm »

E. All of the above
Logged
this sigtext was furiously out-of-date and has been jettisoned

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: Don't Capitalize main()
« Reply #40 on: June 06, 2009, 04:21:38 am »

And if you actually try to learn windows... it's the case sensitive nightmare :P

 ??? ??? ??? The Windows filesystem isn't case sensitive. Linux (et al) is. I assume you're mean something else?
I was actually talking about the Win32 Api wich I've been toying with recently... LPSTR lpCmdLine... you know what I mean... :P
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

Mohreb el Yasim

  • Bay Watcher
  • ♫♪♫♫♪♫♪♪♫♪
    • View Profile
Re: Don't Capitalize main()
« Reply #41 on: June 06, 2009, 06:08:46 am »

actually the big problem is that there are capital letters ... if there won't be the world woud be much easier ... but the real thing wich made me sad is that in C i couldn't do this with an int variable:
nextValue++%=6;
it would be just so cool if i could (it is for boucling values, so it goes from 0-5 and rebegins ...)

I don't even get what you're trying to do? You're trying to set the modulo of (nextValue + 1) to 6? First of all, setting the modulo can't ever define the number because 6%5 = 1, but also 11%5 = 1, and secondly, you'd need to define a second variable for the modulo operator because it can't work with only one.

What you could do is:

nextValue = nextValue%6

If it's 0 or 6 (or 12 or 18...), it returns 0 and if it's between 1 and 5 or between 7 and 11 et cetera, it'll return the remainder of the division (in other words, 1 for 1, 7, 13 etc. 2 for 2, 8, 14 etc. and so on)

Adding in the ++ operator would only mess up things (It'd return 0 at 5, 11 etc and 1 at values of 0, 6, 12 etc)

actualy i wanted (and made in a clearer way 'cause it is programming at work;) go a number each time growing with one until a limit ex.6 and then go back to 0. cause it wil be 0 in begining then 1 (mod 6 still 1) then 2 ... and when it grows to 6 it go back to 0 (6%6=0) it was used to go around in a tabel ... the ugly way (var++%=6 is just for fun and less character/comprehension in the code ...
Logged
Mohreb el Yasim


GENERATION 24:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experime

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Don't Capitalize main()
« Reply #42 on: June 06, 2009, 04:07:37 pm »

Mohreb, does that "ugly way" actually work? In any language? Just curious.

@Alexhans:  :o wow... does it actually have any functions (or whatever) that are named the same except for case?
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Sergius

  • Bay Watcher
    • View Profile
Re: Don't Capitalize main()
« Reply #43 on: June 09, 2009, 05:39:32 pm »

In C++ it will fail to compile, but throws an error that will send you digging through code for hours. Naturally, while other errors can tell you what line they are on, if the compiler can't find main() (even though it CAN find Main(), it just doesn't know what to do with it), it doesn't know where the problem is.

Which makes sense, since the compiler can't point the exact line in the source where something isn't.
Logged

PTTG??

  • Bay Watcher
  • Kringrus! Babak crulurg tingra!
    • View Profile
    • http://www.nowherepublishing.com
Re: Don't Capitalize main()
« Reply #44 on: June 10, 2009, 04:25:37 pm »

Little question, folks.

If I have four values and I want to determine which value is greatest, and be able to return what value that was, how would I do that?

For instance, if I have the following values:
x=0.02
y=0.51
z=0.76
a=0.44

I want to return "3" because the third value is the greatest.

I'm also open to other ways to select the most significant value.
Logged
A thousand million pool balls made from precious metals, covered in beef stock.
Pages: 1 2 [3] 4