CodeBlocks vs Dev c++

Pages: 12
Uh, I think you are not using real double quotes(" - yours look kinda like this `` ´´) in the third #include.

And I know what visual c++ is O_o.

Aside from that, you don't actually have a CandyBox.h in that project.
Last edited on
Code in the image is from book c++ Ivor Horton, so that i only copy-paste it , but it is not working, perhaps intentionally they write the wrong code.

I did not know that it will be so hard at the beginning.
Don't just copy-paste sourcecode if it's not plain text. It may contain smartquotes, ( as it's the case there ):
Replace all double quotes with the ASCII " character.
The book should show the definition of the header or give a link to where you can get it
How to know wich code is for which option, is it CLR, win 32, general, or something third?



I tried this code but it does not work, if you succeed, can you tell me how?

http://www.cplusplus.happycodings.com/Computer_Graphics/code5.html
How to know wich code is for which option, is it CLR, win 32, general, or something third?

Start from Empty Project ( not CLR )

I tried this code but it does not work, if you succeed, can you tell me how?

http://www.cplusplus.happycodings.com/Computer_Graphics/code5.html

That code is VERY old, for DOS programming and nonstandard ( void main )
Ok, but when i try to use empty project i cant write code, like this:

http://img860.imageshack.us/f/cantwrietcode.png/
Right click on source files, and create a new one... I know VC++ can be confusing (I have troubles with it myself) but it should be obvious that you need to create a file you can write to.

Right click on source files, and create a new one( i go all that , but then i choose new item), is that what i should do?


Is this code working for you?

// WhileDemo - input a loop count. Loop while
// outputting astring arg number of times.
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// input the loop count
int loopCount;
cout << “Enter loopCount: “;
cin >> loopCount;
// now loop that many times
while (loopCount > 0)
{
loopCount = loopCount - 1;
cout << “Only “ << loopCount << “ loops to gon”;
}
// wait until user is ready before terminating program
// to allow the user to see the program results
system(“PAUSE”);
return 0;
}
I already told you before, you got some funky characters where you should have " s.

Other than that, it should work, minus the fact you are including cstdio and cstdlib for no real reason.

Pro tip: replace system("Pause"); by
1
2
cout<<"Press Enter to continue";
cin.ignore(cin.readbuf->inAvail()+1);

-- does the same thing but saves you from having to include cstdlib.
Hi baranjac123, as a C++ newbie, if you follow the code in most of these books you are bound to come across a lot of errors. Firstly, because of generally bad and buggy programming and secondly, the fact is that the compilers they were using at the time these books were written, are likely not to be the same as the ones you are using now.

Even versions of the same compiler like Visual Studio Express are not always backward compatible with code written on earlier versions. Similarly, you cannot effortlessly transfer Visual C++/MFC programs written on Visual Studio Express to Mingw C++ compilers, and vice-versa.

This means you may actually have perfectly working code but no compiler to compile it on, without errors.

Lots of code written in the early 2000's no longer works for one or more of these reasons, so if you seriously want to learn c++ programming, you have a decision to make. To go with Visual C++/MFC and the Visual Studio Express train (2005, 2008, 2010); or to go with pure C++/Win32 api and MinGW C++ compilers like Dev C++, Codeblocks, Wxwidgets etc.

The best newbie C++ programming series I have seen on the net is at: http://www.functionx.com/cpp/

They also have Visual C++/MFC tuts as well at http://www.functionx.com/visualc/

For win32 api try: http://www.functionx.com/win32/index.htm and http://www.winprog.org/tutorial/

If you insist on watching videos, try http://xoax.net/

As a parting shot, don't look at errors as the end of the world, because you will come across them all over the net as well as in those pesky books.

I have been there and know how frustrating it can be, but the key is to learn why the code doesn't work, and if it can be fixed - how to fix it. And if it can't be fixed, what alternative code you can use to solve the problem.

I wish you all the best in your journey.

Last edited on
Topic archived. No new replies allowed.
Pages: 12