Mundane C tricks ...
Moderator: InsideQC Admins
Re: Mundane C tricks ...
Ah, yes, memset and C++ objects is dangerous (more charred fingers). I learned to go very carefully though the list of fields in my constructors.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: Mundane C tricks ...
The code was allready there from stock ID source so might have been an oversight when they started porting stuff from C to C++
atleast its Things that teach you to be very carefull not to treat OO code the same as C hehe.
I learn a bit more every day and while most C operations are also valid in C++ there are a few differences like the
beforementioned example that one has to be aware of.
And merry Christmas all
atleast its Things that teach you to be very carefull not to treat OO code the same as C hehe.
I learn a bit more every day and while most C operations are also valid in C++ there are a few differences like the
beforementioned example that one has to be aware of.
And merry Christmas all
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Mundane C tricks ...
I just discovered printf "%g". I swear I've read printf formatting docs a million times.
It is rather difficult to identify which version of C it became a standard, so maybe this format specifier didn't always exist or something.
%g prints a float, but without the superfluous zeros 1.000000000000000000000
/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
It is rather difficult to identify which version of C it became a standard, so maybe this format specifier didn't always exist or something.
%g prints a float, but without the superfluous zeros 1.000000000000000000000
/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Re: Mundane C tricks ...
Yeah, %g is nice. QF has been using it for a while (especially in that builtin that goes to pains to strip trailing 0s). I've almost forgotten %f exists
.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
- taniwha
- Posts: 399
- Joined: Thu Jan 14, 2010 7:11 am
Re: Mundane C tricks ...
Baker wrote:/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
Yeah, got same problem here, I was thinking I3D hated my Opera mobile but since I am not the only one having a hard time to login maybe someone could check what's wrong.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Re: Mundane C tricks ...
The skygods are testing us, to see if we are worthy. Zeus and his friends are having a laugh right now, at our expense ...frag.machine wrote:Baker wrote:/Strange that I had to clear cookies in browser to log-in to this site successfully. Without doing so, I got logged out immediately any time I tried in the last few days, and a crapton of PHP header "already included" stuff appears atop the page.
Yeah, got same problem here, I was thinking I3D hated my Opera mobile but since I am not the only one having a hard time to login maybe someone could check what's wrong.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Re: Mundane C tricks ...
Heh recently discovered %p for printing pointers, somewhat weird experience since earlier msvc newer bitched about using any of the other print types but msvc2012 seems to have taken a new approach (%p also Works in msvc2010 but i havent tried in earlier versions yet).
Kinda hope clang catches up and will be supported by C::B its error checking is a revelation compared to gcc's but speedwise it still lacks some compared and it has no own standard library yet that im aware of so it uses gcc's.
Kinda hope clang catches up and will be supported by C::B its error checking is a revelation compared to gcc's but speedwise it still lacks some compared and it has no own standard library yet that im aware of so it uses gcc's.
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Mundane C tricks ...
reckless wrote:Heh recently discovered %p for printing pointers
I've had better luck at locating good printf tricks in recent times like printf ("%-20.20s", fixed_length_printing_string);
Or %x, even %c
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
Who is online
Users browsing this forum: No registered users and 1 guest