Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 409 410 [411] 412 413 ... 795

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 818251 times)

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6150 on: August 16, 2014, 10:25:34 pm »

How do I memcmp? I am trying to make a program that goes through a binary file and finds a given value.

Code: [Select]
unsigned long searchData = 0;
for(int i = 0; i < file.uncompressedSize-3; i++)
{
if (!memcmp(&searchData, file.uncompressedData + i, 4));
{
fwrite(&searchData, 4,1, stderr);
fprintf(stderr, "|");
fwrite(file.uncompressedData + i, 1,4, stderr);
fprintf(stderr, "\n");
}
}

writes (as shown in notepad++)


Which are clearly not equal
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6151 on: August 16, 2014, 11:51:36 pm »


      if (!memcmp(&searchData, file.uncompressedData + i, 4));
should not have the semicolon at the end (because this is a null statement, meaning that the subsequent block is always executed)
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6152 on: August 17, 2014, 12:11:13 am »

Out of curiosity, what compiler are you using and what warning level?  I would hope that most compilers would have some kind of warning for that.  I've seen that mistake a few times on loops, which leads to quite frustrating debugging to say the least.
Logged
Through pain, I find wisdom.

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6153 on: August 17, 2014, 12:15:35 am »


      if (!memcmp(&searchData, file.uncompressedData + i, 4));
should not have the semicolon at the end (because this is a null statement, meaning that the subsequent block is always executed)

...
Awww damn it, that fixed it.
(how did I miss that :()

Out of curiosity, what compiler are you using and what warning level?  I would hope that most compilers would have some kind of warning for that.  I've seen that mistake a few times on loops, which leads to quite frustrating debugging to say the least.

Code: [Select]
g++ fileutil.cpp -std=c++11

with cygwin. It would be great if there was at least a warning for something like that.
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6154 on: August 17, 2014, 12:36:13 am »

Hmm, no idea what warning level g++ assumes, but I think there's a option call -wall that increases the warning level.  I'd test it here but I'm on Windows without Cygwin.

Actually, I checked and found this: advice on gcc / g++ flags.
Logged
Through pain, I find wisdom.

Maklak

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6155 on: August 19, 2014, 02:04:40 am »

With gcc I generally use --Wall --Wextra
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral

tuypo1

  • Bay Watcher
  • i really apreciate a good analogy
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6156 on: August 19, 2014, 02:09:43 am »

i realized i know a pitifully small amount about programing so i picked up a copy of learning web app development from the libary
Logged
important project progress

have some basic idea of whats going to go in it

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6157 on: August 19, 2014, 06:07:53 am »

i realized i know a pitifully small amount about programing so i picked up a copy of learning web app development from the libary

Node, Redis, Mongo, CloudFoundry. That's basically Buzz Words: Let's Learn Them.

I don't know if I would inflict Node on anyone who is just starting out. Maybe start with the basics of programming.
Logged

tuypo1

  • Bay Watcher
  • i really apreciate a good analogy
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6158 on: August 19, 2014, 06:13:32 am »

i realized i know a pitifully small amount about programing so i picked up a copy of learning web app development from the libary

Node, Redis, Mongo, CloudFoundry. That's basically Buzz Words: Let's Learn Them.

I don't know if I would inflict Node on anyone who is just starting out. Maybe start with the basics of programming.

i do know the basics and the books all javascript
Logged
important project progress

have some basic idea of whats going to go in it

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6159 on: August 19, 2014, 06:20:27 am »

... the books all javascript

If this is the book you picked up, the buzz words don't start up until later. I guess it's not a bad book to use.
Logged

tuypo1

  • Bay Watcher
  • i really apreciate a good analogy
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6160 on: August 19, 2014, 06:23:14 am »

... the books all javascript

If this is the book you picked up, the buzz words don't start up until later. I guess it's not a bad book to use.
yep thats the one do you have any idea why the hell they put that on the cover
Logged
important project progress

have some basic idea of whats going to go in it

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6161 on: August 19, 2014, 06:26:41 am »

In my experience a lot of books about programming assume you already know things about programming.  The target audience seems to be people who already know one language and want to learn another.

Of course that experience is from ~7 years ago.

http://www.codecademy.com/ can teach several languages and helped me a good amount with Python.  The main lessons only cover the basics though.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

tuypo1

  • Bay Watcher
  • i really apreciate a good analogy
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6162 on: August 19, 2014, 06:28:39 am »

In my experience a lot of books about programming assume you already know things about programming.  The target audience seems to be people who already know one language and want to learn another.

Of course that experience is from ~7 years ago.

http://www.codecademy.com/ can teach several languages and helped me a good amount with Python.  The main lessons only cover the basics though.
it does assume a basic knowledge of things like if, else ,loops and other things which i do have but other then that it assumes no knowladge

i will probably go on that website anyway as the preface does mention it its a pretty new book
Logged
important project progress

have some basic idea of whats going to go in it

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6163 on: August 19, 2014, 06:58:48 am »

... the books all javascript

If this is the book you picked up, the buzz words don't start up until later. I guess it's not a bad book to use.
yep thats the one do you have any idea why the hell they put that on the cover

Because Gnu.

Also, today I learned the evils of static.
Logged

Arx

  • Bay Watcher
  • Iron within, iron without.
    • View Profile
    • Art!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6164 on: August 19, 2014, 09:23:04 am »

In my experience a lot of books about programming assume you already know things about programming.  The target audience seems to be people who already know one language and want to learn another.

Of course that experience is from ~7 years ago.

http://www.codecademy.com/ can teach several languages and helped me a good amount with Python.  The main lessons only cover the basics though.
it does assume a basic knowledge of things like if, else ,loops and other things which i do have but other then that it assumes no knowladge

i will probably go on that website anyway as the preface does mention it its a pretty new book

How to Think Like a Computer Scientist is solid for learning Python, Java, or (I think) C++. I don't think there's a Javascript version, though.
Logged

I am on Discord as Arx#2415.
Hail to the mind of man! / Fire in the sky
I've been waiting for you / On this day we die.
Pages: 1 ... 409 410 [411] 412 413 ... 795