• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

I can't tell if my code is actually deleting the detached nodes of a linked list. Here's the code for the delete function. It is simply supposed to delete the first node of the linked list, as a queue.

void delNode(node *&head)
{
node *temp = head;
head = temp->next;
delete [] temp;
}


The program works, but I am not sure if I am actually deleting it.

Why are you using delete[]? You should just be using delete. Aside from that your code looks fine
 

Two Words

Member
Why are you using delete[]? You should just be using delete.

You're right. We've been working with dynamic arrays, for a while so I got used to using [] a lot. But is that correct? if I delete temp, which is pointing to the former head node, does it delete that memory hold from the heap?
 
Yes it should be fine. Run it under a debugger and add a watch for head and temp. After you execute the delete line all of temps fields will turn to junk and all of heads will still be fine
 

Haly

One day I realized that sadness is just another word for not enough coffee.
Question, do you really need to pass that pointer in by reference? Wouldn't delete work even if it's a copy?
 
Codeblocks.

Haven't used it but there should be a window or panel you can open called "watches". So open that. Then put a breakpoint at the first line of the function. Run the program and it will stop. In that watch window, add a new one and type head for the name. Do the same with temp. Now look for "step over". Each time you step, the values in the window will change
 

JesseZao

Member
Anyone heard of or used "Stone River Academy/eLearning"?

I'm looking for more advanced content to supplement my skills and learning and was considering the program because it's on sale atm.

Edit: Seems like it's a amateur shotgun approach at breaking into the online learning field. Looks like a bunch of junk with a few possible interesting courses. I can't seem to find any professional reviews about the site and they don't seem to have had many visitors to their youtube page and their apps have been basically ignored by the market. Them having a firesale for their "lifetime" subscription doesn't really look that attractive when they are barely relevant as a company at this point. Unless somebody else has used their site before, I'm getting a very "click bait" e-learning site vibe from them.

Basically, I'm looking for something to move on to from since I exhausted codecademy. I don't like the idea of monthly subs (like with codeschool or team treehouse), but I want reputable and quality content.
 

JesseZao

Member
^What exactly are you looking for?

If you want to learn some fundamental stuff try Coursera. It has brilliant courses.

Basically, online interactive learning courses like codecademy, but more advanced. Stuff to fill in gaps from my coursework or stuff I haven't gotten to yet and want a head start. (ruby, python, swift, mvc, web development tools like less/sass/bootstrap/etc.)

Codecademy was good for me because I didn't have to watch and listen to a video and I learned by doing (and it's free). I could do it while I'm at work or doing other things.

Coursera looks like a great resourse for general topics. I'm looking for a more focused learning tool that is text-based so you can go at your own pace.

edit: Data Science from Coursera looks very interesting and you learn R. I think I'll do that next.
 

Mr.Mike

Member
Basically, online interactive learning courses like codecademy, but more advanced. Stuff to fill in gaps from my coursework or stuff I haven't gotten to yet and want a head start. (ruby, python, swift, mvc, web development tools like less/sass/bootstrap/etc.)

Codecademy was good for me because I didn't have to watch and listen to a video and I learned by doing (and it's free). I could do it while I'm at work or doing other things.

Coursera looks like a great resourse for general topics. I'm looking for a more focused learning tool that is text-based so you can go at your own pace.

Sounds like you might be best served by picking up books with lots of examples that you can work through.
 

Azure J

Member
Just curious, is there a good series of downloadable video tutorials/lessons to follow similar to the C# Fundamentals for Absolute Beginners series? I'm interested in learning C# and C++ for obvious game engine use but I'd also just like to get in the groove of regularly playing with and writing code after a long time.
 
Just curious, is there a good series of downloadable video tutorials/lessons to follow similar to the C# Fundamentals for Absolute Beginners series? I'm interested in learning C# and C++ for obvious game engine use but I'd also just like to get in the groove of regularly playing with and writing code after a long time.


Try thenewboston YouTube tutorials for c++ basics. Then if you want to further enhance your knowledge read trough learncpp.com website which covers almost everything from basics to advanced stuff. I use it as my c++ reference.

For c# there is this Coursera video lectures couese which teaches c# along with game programming in XNA. I haven't tried it but I believe it would be pretty good. I am also planning to learn c# and unity.
 

Water

Member
Just curious, is there a good series of downloadable video tutorials/lessons to follow similar to the C# Fundamentals for Absolute Beginners series? I'm interested in learning C# and C++ for obvious game engine use but I'd also just like to get in the groove of regularly playing with and writing code after a long time.

Just my opinion, but if you want to learn both, don't touch C++ at least until you are fluent with C#. The way to fundamentally grow as a programmer is to code increasingly hard things. Learning a language is a necessary initial step to that direction, just as learning to use a natural language is a necessary step on the way to becoming a great storyteller, but rushing to learn a second language early is really only taking time away from the important stuff.
 
Anyone have experience with those programming boot camps that have been popping up, or general thoughts on the concept?

I would say that if you're a self starter then they won't help you much, and if you're not a self starter then programming might not be the right career for you. I'm not saying you won't learn some valuable languages and technologies, just that there's a strong personality/attitude requirement to advance from entry/mid level to senior that imo doesn't overlap much with the type of people that the bootcamps and whatnot are marketed towards. I think they're probably great for the more entrepreneurial types who don't actually want to write code though.
 

NotBacon

Member
Basically, online interactive learning courses like codecademy, but more advanced. Stuff to fill in gaps from my coursework or stuff I haven't gotten to yet and want a head start. (ruby, python, swift, mvc, web development tools like less/sass/bootstrap/etc.)

Codecademy was good for me because I didn't have to watch and listen to a video and I learned by doing (and it's free). I could do it while I'm at work or doing other things.

Coursera looks like a great resourse for general topics. I'm looking for a more focused learning tool that is text-based so you can go at your own pace.

edit: Data Science from Coursera looks very interesting and you learn R. I think I'll do that next.

Udacity
 

nOoblet16

Member
Man I swear the more I go into theoretical computer science the more I forget about programming considering I don't practice it much, even basic level stuff escapes me at times. So here is a piece of a simple C code I wrote a while ago that takes one input such as ABCDEFGHIJKLMNOPQRUSTVWXYZabcdefghijklmnopqrstuvwxyz and outputs NOPQRUSTVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

Basically splitting both the upper case (A-Z) and the lower case (a-z) at M & m respectively and swaps their places.


Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i = 0;
    char str[512];
    gets(str);
    while(str[i] != '\0')
    {
        if( (str[i] >= 'A' && str[i] <= 'M') || (str[i] >= 'a' && str[i] <= 'm') )
            str[i] += 13;
        else
            if(str[i] >= 'N' && str[i] <= 'Z')
                str[i] = 'A' + (str[i] - 'N'); //for "N" it will be "A"
            else
                if(str[i] >= 'n' && str[i] <= 'z')
                    str[i] = 'a' + (str[i] - 'n'); //for "n" it will be "a"
        i++;
    }
    puts(str);
    return 0;
}


What I want to do is change it in a way so that it takes the same input but outputs DEFGHIJKLMNOPQRSTUVWXYZABCdefghijklmnopqrstuvwxyzabc. Meaning it looks at each character starting from the first and replaces it with the character 3 places to its right and does it for both the upper case and lower case alphabets separately despite them being part of the same string.

I know the concept is similar to how you reverse a string but instead of swapping i-th character with the one at (n-i), I have to swap i with the character at (i+3).

Question is how do I implement it in a manner that it works for both the upper case and lower case set of letters which are all part of one string array. I would really appreciate any help on this.
 
Man I swear the more I go into theoretical computer science the more I forget about programming considering I don't practice it much, even basic level stuff escapes me at times. So here is a piece of a simple C code I wrote a while ago that takes one input such as ABCDEFGHIJKLMNOPQRUSTVWXYZabcdefghijklmnopqrstuvwxyz and outputs NOPQRUSTVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

Basically splitting both the upper case (A-Z) and the lower case (a-z) at M & m respectively and swaps their places.


What I want to do is change it in a way so that it takes the same input but outputs DEFGHIJKLMNOPQRSTUVWXYZABCdefghijklmnopqrstuvwxyzabc. Meaning it looks at each character starting from the first and replaces it with the character 3 places to its right and does it for both the upper case and lower case alphabets separately despite them being part of the same string.

I know the concept is similar to how you reverse a string but instead of swapping i-th character with the one at (n-i), I have to swap i with the character at (i+3).

Question is how do I implement it in a manner that it works for both the upper case and lower case set of letters which are all part of one string array. I would really appreciate any help on this.

Try to write this function:

Code:
void rotate_string(char* str, int str_len, int split_position)
{
}

Description: Given |str_len| characters in a string which is pointed to by |str|, take the first |split_position| characters and move them to the end of the string.

Some things to note: |str| is not necessarily null-terminated in this function. That's why you have |str_len|. Also, it modifies the string in place.


An example of using this function might be like this:

Code:
char *my_string = "0123456789ABCDEF";
rotate_string(my_string+6, 8, 2);
// my_string should equal "01234589ABCD67EF"
012345|6789ABCD|EF
  vvv    vvv
   6      8

So the 6 and 8 come from the above diagram, and the 2 comes from the fact that the first 2 characters at the beginning of the 8-character sequence are moved to the end, with the other 6 pushed left.

After you write this function, use it to solve the original problem.
 

Azure J

Member
Try thenewboston YouTube tutorials for c++ basics. Then if you want to further enhance your knowledge read trough learncpp.com website which covers almost everything from basics to advanced stuff. I use it as my c++ reference.

For c# there is this Coursera video lectures couese which teaches c# along with game programming in XNA. I haven't tried it but I believe it would be pretty good. I am also planning to learn c# and unity.

Just my opinion, but if you want to learn both, don't touch C++ at least until you are fluent with C#. The way to fundamentally grow as a programmer is to code increasingly hard things. Learning a language is a necessary initial step to that direction, just as learning to use a natural language is a necessary step on the way to becoming a great storyteller, but rushing to learn a second language early is really only taking time away from the important stuff.

Thanks guys. :)

Water, I came to that conclusion today but it's good to hear the thought behind it all.
 

Slavik81

Member
Is catching ArrayIndexOutOfBoundException normal in Java code? As a C++ guy, I habitually check my array bounds rather than relying on the automatic bounds check.
 
Just curious, is there a good series of downloadable video tutorials/lessons to follow similar to the C# Fundamentals for Absolute Beginners series? I'm interested in learning C# and C++ for obvious game engine use but I'd also just like to get in the groove of regularly playing with and writing code after a long time.

Unless you want to write your own game engine, just dive into Unity. It uses C#, has plenty of tutorials and videos on its own site.
 

SKINNER!

Banned
Guys, needing a bit of advice.

I graduated with a software engineering degree back in uni predominantly working with Java. Although I enjoyed it when things worked, I sometimes got equally frustrated with it. It was kinda a love/hate relationship. After graduation, I took up an entry level role in a company thinking I'd be involved with more software development but it was more of an analyst role and the only technical thing I've been hands-on with is SQL. Anything technical heavy would be outsourced to developers in India/China and I'd only be advising them on what needs to be changed.

I'm looking into getting back into programming skills as an investment to further progress my career and see if I still got it, mobile development maybe, basically familiarise myself with techniques and - eventually - create a portfolio with applications. Unsure if anyone has been in the same situation as I am but, apart from re-doing basic/intermediate tutorials, is there any textbooks/websites/courses/certificates(?) or exercises I can do to get myself into a progamming mentality? I'm like "I know about loops, iterations etc. and all that but I don't know how to incorporate them into solving problems".

Thanks in advance.
 

nOoblet16

Member
basically just want to make each case closed over incrementation of their ascii values

I managed to do it but the code only works if I use ABCDEFG...and so on.

What if the string I use has a different set of alphabets, how do I rotate it to right by 3 ? I tried to change it so that it only takes into consider the array index and swaps whatever value the indices store but it didn't really work. This is basically the ROT13 substitution cipher but with 3 spaces.
 
I managed to do it but the code only works if I use ABCDEFG...and so on.

What if the string I use has a different set of alphabets, how do I rotate it to right by 3 ? I tried to change it so that it only takes into consider the array index and swaps whatever value the indices store but it didn't really work. This is basically the ROT13 substitution cipher but with 3 spaces.

Did you try writing the function i suggested and thinking about how to apply it to this problem? Maybe that's what you meant by you tried and it didn't work? What part didn't work? Some code for that would be helpful. (I'm intentionally not giving too much detail, because it's important for you to mostly solve the problem by yourself.)
 

KageZero

Member
Hello,
im thinking about starting to program in c++ once again since i have a project in mind and would like to complete it in this language. Before i worked a bit in c++ (mostly college stuff) and since i come back to it from c# and java i think i should also repeat a bit about pointers and stuff so i need some good tutorials/books which are lets say intermediate level at least.

My idea for the project resolves about sound capture from instruments(some basic stuff for recognition of each individual sound if possible) so if someone has some idea from where should i start i would be really grateful since i never worked on something like this.
 
Further to my earlier discussions with cpp_is_king about programming tools, here's a welcome news item I saw today. edX, pioneers in online higher education, are partnering with Microsoft to deliver courses on important programming tools in the Microsoft environment (including C# and PowerShell). You can either pay a fee and get a certificate, or audit the course for free. I've never done an EdX course but I've done several in this genre and highly recommend it to those who can commit to the work but have limited resources.

https://www.edx.org/press/edx-collaborates-microsoft-launch-it
 
Don't you just love it when you spend hours stepping through and double checking code for something going wrong, and then realize you just set some property value incorrectly?
 

egruntz

shelaughz
Okay guys. Looking for guidance. I know HTML, CSS, JavaScript, jQuery--that is, I know the basics.

I want to build a website similar to Neopets, but focusing not on virtual pets but on turn-based PvE/PvP battle systems and world exploration. I mean "similar to Neopets" in the way of events being handled in real time/automatic updates (shop refreshes) and that sort of thing. Accounts keeping track of progress, where characters have been, yada-yada. You get the idea. Basically I want a website game, where the world is hosted in the browser.

What programming languages do I need to know? I am so clueless and lost. I know how to build basic, static websites and I know how to implement some interactive/responsive design tools, but I don't even know where to get started in building a world/website like that.

What languages am I lacking that will be essential for this? What tools should my website be built with? (Flash, etc.?) Any guidance would be appreciated. I know this will be a difficult and long process. Just looking for the place to start.

I'm often given the "if you don't know where to start, you're not ready" response and that frustrates me. Cause I spend hours on hours on hours of my freetime learning coding. And I can only repeat the basics so many times. I don't know how to turn what I've learned into the game in my head. Help please? :(
 

NotBacon

Member
Okay guys. Looking for guidance. I know HTML, CSS, JavaScript, jQuery--that is, I know the basics.

I want to build a website similar to Neopets, but focusing not on virtual pets but on turn-based PvE/PvP battle systems and world exploration. I mean "similar to Neopets" in the way of events being handled in real time/automatic updates (shop refreshes) and that sort of thing. Accounts keeping track of progress, where characters have been, yada-yada. You get the idea. Basically I want a website game, where the world is hosted in the browser.

What programming languages do I need to know? I am so clueless and lost. I know how to build basic, static websites and I know how to implement some interactive/responsive design tools, but I don't even know where to get started in building a world/website like that.

What languages am I lacking that will be essential for this? What tools should my website be built with? (Flash, etc.?) Any guidance would be appreciated. I know this will be a difficult and long process. Just looking for the place to start.

I'm often given the "if you don't know where to start, you're not ready" response and that frustrates me. Cause I spend hours on hours on hours of my freetime learning coding. And I can only repeat the basics so many times. I don't know how to turn what I've learned into the game in my head. Help please? :(

Not Flash. Sorry that's all I can tell you haha.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
As a rough guess, you'll probably have to pick up databases as well.
 
As a rough guess, you'll probably have to pick up databases as well.

Definitely. This is where things get complicated. I would say start with a simple webpage that connects to a webserver and allows you to create an account. You enter a username and password, some info about yourself, and it sends that to the web server and the server writes it to the database. I don't know what's "in" these days, so I'll suggest MySQL just to name drop. From there make a page that that lets you display your account info if you enter your username and password.

Don't ask me how to do any of this stuff, i have no idea. I can implement a database, or a web server but I haven't the first idea how to connect it all together. :)

But the first step is to start small and don't focus too hard on the end goal. You need to learn a lot of stuffs to get there, and making mistakes along the way is part of the process.
 
Hello,
im thinking about starting to program in c++ once again since i have a project in mind and would like to complete it in this language. Before i worked a bit in c++ (mostly college stuff) and since i come back to it from c# and java i think i should also repeat a bit about pointers and stuff so i need some good tutorials/books which are lets say intermediate level at least.

My idea for the project resolves about sound capture from instruments(some basic stuff for recognition of each individual sound if possible) so if someone has some idea from where should i start i would be really grateful since i never worked on something like this.
If you're really interested in audio programming, I've been slowly making my way through the following book, which has been suggested by a few websites for the purpose of developing virtual musical instruments of the VST sort, for use in Cubase or Pro Tools.

The Audio Programming Book starts with a quick intro to C, just enough C++, and goes into several examples of real time audio programming with the Csound library. Half the almost 900 page book (no joke) is a crash course discussion of C/C++ programming fundamentals with occasional references to music theory, as they've tried to make this accessible to a wider audience.

I like the coverage of material, and I don't think it skips out on stuff. It does make me want to try a course that covers music composition and playing someday, maybe a Ukulele course is in my future?

That's probably the sanest way to dive in that I know of. Csound abstracts a fair number of audio recording and capture APIs that can be either messy to manage and very OS specific or too high level to do anything interesting with, and it offers some nice plugin interfaces to change waveforms in real time. It's cool stuff.

Give it a shot, take it easy, and don't get too intimidated. It's a fascinating subject on its own.
 
Guys, needing a bit of advice.

I graduated with a software engineering degree back in uni predominantly working with Java. Although I enjoyed it when things worked, I sometimes got equally frustrated with it. It was kinda a love/hate relationship. After graduation, I took up an entry level role in a company thinking I'd be involved with more software development but it was more of an analyst role and the only technical thing I've been hands-on with is SQL. Anything technical heavy would be outsourced to developers in India/China and I'd only be advising them on what needs to be changed.

I'm looking into getting back into programming skills as an investment to further progress my career and see if I still got it, mobile development maybe, basically familiarise myself with techniques and - eventually - create a portfolio with applications. Unsure if anyone has been in the same situation as I am but, apart from re-doing basic/intermediate tutorials, is there any textbooks/websites/courses/certificates(?) or exercises I can do to get myself into a progamming mentality? I'm like "I know about loops, iterations etc. and all that but I don't know how to incorporate them into solving problems".

Thanks in advance.
Shot in the dark. You mentioned mobile, and this is a book that came highly recommended to people just starting out in iOS.

Beginning iPhone Development with Swift is an update of a well regarded book that was originally penned by Jeff Lamarche for Objective-C. You might dig it.

Android is also an option, but I don't know offhand about a similar, entry level text. I came into Android at a very low level (NDK, so C/C++ and JNI interfaces to Java APIs) and at the time, the joke was that every Android programmer group in NYC was 99.5% recruiters and 0.5% experienced Java guys.
 

survivor

Banned
Okay guys. Looking for guidance. I know HTML, CSS, JavaScript, jQuery--that is, I know the basics.

I want to build a website similar to Neopets, but focusing not on virtual pets but on turn-based PvE/PvP battle systems and world exploration. I mean "similar to Neopets" in the way of events being handled in real time/automatic updates (shop refreshes) and that sort of thing. Accounts keeping track of progress, where characters have been, yada-yada. You get the idea. Basically I want a website game, where the world is hosted in the browser.

What programming languages do I need to know? I am so clueless and lost. I know how to build basic, static websites and I know how to implement some interactive/responsive design tools, but I don't even know where to get started in building a world/website like that.

What languages am I lacking that will be essential for this? What tools should my website be built with? (Flash, etc.?) Any guidance would be appreciated. I know this will be a difficult and long process. Just looking for the place to start.

I'm often given the "if you don't know where to start, you're not ready" response and that frustrates me. Cause I spend hours on hours on hours of my freetime learning coding. And I can only repeat the basics so many times. I don't know how to turn what I've learned into the game in my head. Help please? :(
Since this is a multiplayer game and I think MMO-lite you will need a server to keep track of players info and what not. So you need a backend language. There are lots of options like PHP, C#, Ruby, Python and so on. Since you know Javascript already, you can try Node.js and write your game server using it.

Also like Haly said, you will need to pick up some SQL thingy for database. You got a variety of options, MySQL, PostgreSQL, NoSQL, but this isn't a big issue. Anything you pick will suit your needs.

As for the game, I'm assuming this is some sort of 3D game right? So you will probably need to pick up something like WebGL. I'm not sure if there are any HTML5 game engines that are 3D, I know there is something like three.js but my knowledge in that area isn't that well. Of course you can use something like Unity3D, but I'm not sure how it handles your game with their web player plugin and how much flexibility you get with it.

Also something to look into when you get further in this is using WebSockets for real-time communication between your game and server. I have seen some people in the past use Socket.io when making online HTML5 games, but I can't speak on its usability. I have only used the thing for trivial features so not sure how well it works for complex apps.
 

injurai

Banned
Don't you just love it when you spend hours stepping through and double checking code for something going wrong, and then realize you just set some property value incorrectly?

Just spent 2 hours tracking down what was two increment variables initialized to the wrong value...

It took 3 rewrites of a function building it up from scratch to finally catch it. No amount of debugging helped, eventually the mistake just jumped out at me. It's good I knew the algorithm inside and out.
 
D

Deleted member 30609

Unconfirmed Member
any c++ IDE recommendations for Mac? I'm not going to be writing any GUI/DX/production code, just some research bits and pieces. Something that automates building, gives me some basic refactoring tools, plays well with git, doesn't screw with the working directory too much and gives me some auto-complete functionality would be ideal.

Xcode seems like the obvious choice, but it might be overkill. I'm already very familiar with Eclipse and vim, but I feel like vim might be a little too lightweight (yes, I know what you're about to type, stop typing) for the project and last time I checked Eclipse's C++ plugins weren't spectacular.
 
So how are these subscription based websites like Treehouse for someone who likes to continue to improve their skills and keep up with new trends? I hear great things about it for those who want to learn who know nothing (Jon Snow).

I have heard good things about Upcase, how are they?
 
Are there any good portable C++ IDEs for windows, which doesn't require installation. Something like zip file version of eclipse for java.

I searched for them and couldn't find any decent one. Any help is appreciated. Thanks.
 
So how are these subscription based websites like Treehouse for someone who likes to continue to improve their skills and keep up with new trends? I hear great things about it for those who want to learn who know nothing (Jon Snow).

I have heard good things about Upcase, how are they?

Pluralsight is pretty good, although they have a slight preference towards Microsoft products. Still, plenty of courses focus on other technologies, and they also offer courses to help career development with courses on for example interviewing, job hunting or LinkedIn usage and such.
 
Top Bottom