Hm, your code doesn't have a main function! You declare one (which isn't needed, by the way), but never define it.
Try this: http://codepad.org/IbSFlOuN
I took the liberty to clean up the indentation, too.
The changes do this:
Line 9: declare the init_board function, that takes a tictactoe_board pointer as an argument. This is needed because we call the function "before" it's defined (the definition is below main()).
main(): Create a board on the stack, and pass it (as a pointer; & is the address-of operator) to init_board.
I'm not sure exactly what has been covered by the lesson you're at; ask again if this isn't clear. :)
You can think of string as containing the memory address of the "H", so the code will work.
Generally speaking, an array name (like "string" in this case) is usually converted to a pointer to the first element of the array.
However, there are subtle differences, which will be expounded on later.
When you create a pointer, you are creating a special kind of variable that can hold (within reason) any memory address you wish. You can add to it, subtract to it, you can work with it in unique ways, and so on.
There are times you might want to re-assign the value of a pointer, and you can do that. You cannot however do that with an array name.
for example:
// You cannot do this
char my_array[] = "Hello"; char my_other_array[] = "World";
my_array = my_other_array;
You cannot do that with arrays, but it is trivial with pointers.
Yes I think you're right.. I've talked to many Redditors in learnprogramming and gamedev who took your lessons, but got bored when they finished and started doing their own thing. I did, so I started this while waiting to finish tic-tac-toe.
I don't know about 'textbook' examples, but maybe look at http://projecteuler.net/
Some of the problems are really advanced, especially in terms of mathematics, but there are some problems that aren't too difficult. Could be a good resource to try and make your mind think differently to solve problems.
I could organize all of the lessons together with LaTeX and upload a PDF over the weekend, with Carl's permission of course.
Send To Reader also works quite well.
Here it is fixed up a bit. passing the whole struct (which isn't the best idea since you have to copy the struct back and forth.)
Here it is fixed so you're passing a pointer.
BTW You should post questions like these in /r/learnprogramming.
Good luck!
I also can't reply to main topic.
This just takes some of the ideas we've used and puts them in a few sentences. I couldn't figure out how to create a string typed variable. I liked making the identity between pointers and their variables in my head. It helped me out a lot.
For anyone who is as confused as me about string variables (because you've used other programming languages before), just continue to lesson 42 and all of your questions will be answered (or at least most of them).
Weird... I'm not using BOOST_BINARY... Here's my GCC specs
dixie@Taisser-Ashpool:~/c$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
Edit: Okay so this seems to suggest that binary constants are supported in C99, but the extension is required for C90 and C++. The wording is a little confusing, but when I compiled with -pedantic, I did not get a warning saying I was using an extensoin.
Hi! I had the same experience when I first start learning! I felt really stupid too! People I asked seem to just say" Just use a text editor!" Like we know what that means. But it's not something super obvious for someone who is completely new. So no worries!
At the time, i have a mac, and I open the default text editor on mac, "TextEdit", but it uses "rich text format" so it didn't work. For non-programmers, they might think:"hey, microsoft word is a text editor, i will use that". But those things don't work as far as I know.
Make sure to use any non-formated text editor. Here is a good one to use: http://www.sublimetext.com/
I do have a problem in something I wrote however: http://codepad.org/ANlCRuTS
I don't see any reason why this won't work. I have resolved the problem by condensing it down to 1 data structure. For future endeavors, I'd like to know why this won't work. Any ideas?
My approach is slightly different to Carl's in the course notes. The AI isn't finished yet (just chooses a random legal move) and there is no input checking (other than against illegal moves), but it works, and is fairly terse: http://codepad.org/dchY4G5z
Newbie question here - looks like the last question thread has expired, sorry if this is the wrong place to post.
I'm trying to write code that will reverse the case (upper/lower) of all characters in a string. I'm through unit 11 or so. Here's my code:
Now there are two things that confuse me here:
Why is my new string stopping at "hELLO"? There should be a space after it, or whatever [space] ^ 0x20 is. Unless a space happens to be 0x20, this shouldn't evaluate to a null stop, right?
Considerably weirder (I think) - the final line of output codepad gives me is ""The new string is hELLO". But when I run this in CodeBlocks, my final line of output is "The new string is ". I really can't figure out how I get "hELLO" on the third to last line but not the final line in CodeBlocks. Help!
Well the back end was written in c++ it was quite easy to write it can be downloaded from here https://sourceforge.net/projects/xorencrypt2/files/files/ this is the file you see named a.exe in the installed folder ,the front end( GUI part) was written with ActionScript 3 in Adobe Flash Builder AS which (you can find on my github) is similar to Javascript and is easy to learn :)
Personally, I'd go with C#. C# is (to my knowledge) the language that is on the rise when it comes to games.
So give C# a shot. It is a lot like Java in syntax. Unity uses some C#, and would be a great way to get your feet wet with both game programming and C#.
This is an old post, but if you haven't figured anything out yet, I use Private Internet Access as my VPN. its ~$3 a month and its very nice.
I used to use a free one but I figured its worth it for only $3 a month to just have much better features.
get a vpn and encrypt all your traffic through it. I live in Germany where I have very limited access to youtube and other content services like it, so I've been using StrongVPN to browse without being bothered by region blocked content. It's not free, but it's the best alternative I've found. Free proxies aren't as useful and don't work that well (IMHO).