Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 485 486 [487] 488 489 ... 796

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

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7290 on: April 28, 2015, 12:02:28 pm »

Find an open source project you're interested in, code for it for a while.
*i2amroy looks pointedly at his signature* :D
you generally want a project with code standards :^] (jk)

i mean i would recommend /tg/station but that's not written in C++ so :P
You could try Dungeon Crawl: Stone Soup, it seems pretty cool.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7291 on: May 01, 2015, 03:24:37 pm »

In a C program I am writing, I have an struct with a struct pointer within it containing an array. I have tried to access it like this

Code: [Select]
struct1->struct2->variable

and then loop through the array using poiner arithmetic as such

Code: [Select]
struct1->struct2++


However, this seems to crash the program, and I am not entirely sure why.


Help?
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7292 on: May 01, 2015, 04:07:42 pm »

Add more parentheses?
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7293 on: May 01, 2015, 04:24:00 pm »

Add more parentheses?
This, unless you can tell us what the error is.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7294 on: May 01, 2015, 04:26:47 pm »

where abouts would I put them?
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7295 on: May 01, 2015, 04:41:38 pm »

In a C program I am writing, I have an struct with a struct pointer within it containing an array. I have tried to access it like this

Code: [Select]
struct1->struct2->variable

and then loop through the array using poiner arithmetic as such

Code: [Select]
struct1->struct2++


However, this seems to crash the program, and I am not entirely sure why.


Help?

ignore that parentheses thing.

Your problem is that "struct2" is the actual array, right? The name "struct2" is actually a memory pointer pointing at the start of the block of data. It should never be changed after you've created the array, because then you will no longer have a handle to access the entire array.

When cycling through an array, you can use a memory pointer, but it should be a copy of the original one. But it's equally easy to use an int and square brackets.
« Last Edit: May 01, 2015, 04:46:04 pm by Reelya »
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7296 on: May 01, 2015, 04:43:37 pm »

I decided to see how hard it would be to upgrade from ruby 1.8.6 to ruby 2.2.2 at work today.

I have discovered that SOMEHOW the ruby tk library slows down my oracle database queries by about 500 fold.  :o  :(  >:(

How does that even make sense?  WTF is a GUI library doing that would break my database drivers.

And i'm not even using it yet.  Its just being included, I haven't called single GUI call yet.  Grrr.

/rant

Edit:  Apparently I need to do this for reasons.
Code: [Select]
module TkCore
  RUN_EVENTLOOP_ON_MAIN_THREAD = true #FIXES BUG IN TK THAT KILLS DB PERFORMANCE.
end
RUN_EVENTLOOP_ON_MAIN_THREAD = true #FIXES BUG IN TK THAT KILLS DB PERFORMANCE.
require 'tk'
#NOW I'M FINE
« Last Edit: May 01, 2015, 05:14:27 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7297 on: May 01, 2015, 05:38:31 pm »

If I send a random person a .py file, will they be able to click on it and run it?  Or does that require having python installed?
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

Cthulufaic

  • Bay Watcher
  • whats a touhou
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7298 on: May 01, 2015, 05:40:48 pm »

If I send a random person a .py file, will they be able to click on it and run it?  Or does that require having python installed?
Probably, but he/she/[tumblr-pronoun-goes-here] can just download IronPython to use it.
Logged

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7299 on: May 01, 2015, 05:41:57 pm »

In a C program I am writing, I have an struct with a struct pointer within it containing an array. I have tried to access it like this

Code: [Select]
struct1->struct2->variable

and then loop through the array using poiner arithmetic as such

Code: [Select]
struct1->struct2++


However, this seems to crash the program, and I am not entirely sure why.


Help?

ignore that parentheses thing.

Your problem is that "struct2" is the actual array, right? The name "struct2" is actually a memory pointer pointing at the start of the block of data. It should never be changed after you've created the array, because then you will no longer have a handle to access the entire array.

When cycling through an array, you can use a memory pointer, but it should be a copy of the original one. But it's equally easy to use an int and square brackets.

Yeah, "struct2" is a 1 dimensional pointed malloced to include an array. I made a copy of the pointer, but used the original for some reason.
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #7300 on: May 01, 2015, 05:47:39 pm »

If I send a random person a .py file, will they be able to click on it and run it?  Or does that require having python installed?
Probably, but he/she/[tumblr-pronoun-goes-here] can just download IronPython to use it.
IronPython only works for Python 2, IIRC. If you want any random person to be able to run it, you're better off compiling it into a binary using one of those utilities floating around, like py2exe or whatever.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7301 on: May 01, 2015, 06:05:45 pm »

Yeah, "struct2" is a 1 dimensional pointed malloced to include an array. I made a copy of the pointer, but used the original for some reason.

Can you show the code allocating the memory and the code assigning to struct2?

Does looping through the original cause the program to crash too?
Logged
Through pain, I find wisdom.

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7302 on: May 01, 2015, 06:13:20 pm »

alright the code for assigning struct 2 memory


Code: [Select]
struct1->struct2 = malloc(10 * sizeof(struct2))


Will update this post in 2 mins when I have tested it.

EDIT:

Yeah still crashes
« Last Edit: May 01, 2015, 06:15:47 pm by gigaraptor487 »
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

gigaraptor487

  • Bay Watcher
  • Escaped Lunatic now civilised
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7303 on: May 01, 2015, 08:01:04 pm »

managed to get it working. This whole time I didn't realise that '->' meant dereference, so i was getting the data pointed to rather than the pointer itself. This was fixed by simply putting the ampersand at the front of the assignment, although the complier complains about it.
Logged
Hehe, you thought there would be an interesting sig here

I now run a program which brings old multiplayer games back to life : click

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #7304 on: May 02, 2015, 05:15:30 pm »

If I send a random person a .py file, will they be able to click on it and run it?  Or does that require having python installed?
They need to have python installed, and often even the correct same version you use.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.
Pages: 1 ... 485 486 [487] 488 489 ... 796