Welcome Guest [Log In] [Register]
Add Reply
Getting Started with C++; what do i use to start c++?
Topic Started: Mar 28 2009, 04:30 PM (891 Views)
MrJoeyUK

Good to see you're jumping right into the deep end and writing code yourself.. I see too many people copy and pasting code into a compiler and claiming to be good programmers. I also use Dev C++, can't go wrong with it..

I'd also reccomend buying a good c++ book somewhere, online tutorials may be good but from my experience of using them (I'm also quite new to programming) they tend to be quite limited and often don't explain the code it is telling you to use very well, it just tells you the code.. sorta like learning to put 2 ounces of sugar into a cake but not learning why you do it, if you understand. :P
Offline Profile Quote Post Goto Top
 
Samael88
Member Avatar

Code:
 
#include<isotream>
using namespace std;

int main()
{
count<< "hello world!";
return(0);
}


Okay, here is what you wrote.

And here is what is wrong with it:
1. It should be "iostream" not "isostream" :P And it might need to be "iostream.h" but I'm not sure.

2. "count" should be "cout".

Another pointer is this: You don't need the brackets() in "return 0;" It is just as good as I wrote it here, it's more if you are returning a complex math-thing or something like this: "return(8*(9+10));".

There is one more thing.
If you write it like that you won't be able to see the result unless you have a really, really slow comp, or you are using dos.

When I work with text-based stuff I do one of these:
Code:
 

#include <conio.h>
#include <iostream>

int main()
{
cout<<"hello world!";
getch();
return 0;
}


Code:
 

#include <iostream>

int main()
{
int a;
cout<<"hello world!";
cin>>a;
return 0;
}


Just to get it to stop there for a while so that one can see the result of what one is doing ;)

getch() is a function that get's a char, which means a single letter. Or any other tangent for that matter.

cin>>a; is a line that tells the program to wait untill it gets an input for a, in this case an integer(whole number, no decimals).

I hope that helps ^_^
Offline Profile Quote Post Goto Top
 
SheWasAlmost18
Member Avatar

yeah i wanted to buy a book yesterday but it cost 25 dollars and i had like 9 =( and yeah books are indeed better
-
yeah i tried your code samuel but i always get 1 error
in the compile log it tells me this

Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\hello\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\hello\Makefile.win" all
make.exe: Circular Untitled1 <- Untitled1.o dependency dropped.

g++.exe -c Untitled1 -o Untitled1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

g++.exe: Untitled1: linker input file unused because linking not done

g++.exe Untitled1.o -o "Hello World.exe" -L"C:/Dev-Cpp/lib"

g++.exe: Untitled1.o: No such file or directory
g++.exe: no input files

make.exe: *** ["Hello] Error 1

Execution terminated

but i dont understand and it says i have 1 error
Edited by SheWasAlmost18, Mar 29 2009, 01:37 PM.
We are made kind by being kind
Offline Profile Quote Post Goto Top
 
Samael88
Member Avatar

Have you moved your dev-c++ after installation?
Have you saved the cpp file?
Are you using a project file or just a plain cpp file?
Offline Profile Quote Post Goto Top
 
Admireable
Member Avatar

SheWasAlmost18
Mar 29 2009, 11:05 AM
since everyone appears to be unfamiliar with code blocks, ill switch to dev c++
the reason i have code blocks was because cprogramming.com recommended it for beginners
ok nice
now im getting started



  • #include<isotream>
    using namespace std;

    int main()
    {
    count<< "hello world!";
    return(0);
    }


this being the first thing I wrote, it says there is an error
and I'm not too sure what a library is but i think it's related to the isostream
can someone find a problem with this code?

never mind my spelling is atrocious
Hi guys am new to this forum but anyways read a few topics abt c programming ... and i am shocked to see no one talking about Standard C only c++ :S
anyways i would prefer Devc++ compiler also for windows platform ! :)

Dont see Your Future in Propietary Products !


The Best Things in da World Are Always Free ;)
There Are 10 Types Of People In This World, One´s Who Understand Binary and Other´s Who Dont !
Offline Profile Quote Post Goto Top
 
SheWasAlmost18
Member Avatar

@samuel no i didnt move the file
and how do i find out if i saved my cpp file
We are made kind by being kind
Offline Profile Quote Post Goto Top
 
Samael88
Member Avatar

did you save the file before you clicked compile and run?
Offline Profile Quote Post Goto Top
 
SheWasAlmost18
Member Avatar

Code:
 

#include <iostream.h>
#include <string>
int main()
{
string mystring = "I am talking to you";
cout << mystring;
return 0;
}


hey I'm trying to make it display I am talking to you but when i compile it I get 4 errors
can someone help?
Edited by SheWasAlmost18, Mar 30 2009, 06:31 PM.
We are made kind by being kind
Offline Profile Quote Post Goto Top
 
Cosmic_AC

Just use
#include <iostream>
instead of
#include <iostream.h>

Also, you forgot
using namespace std;
or just
std::cout << mystring;

And again, when you run it, it'll close immediately unless you ask for input with something like
cin.get()
Edited by Cosmic_AC, Mar 31 2009, 05:10 AM.
++++++++++[>+++++++>+++++++++++<<-]>---.>+.++++.------.----.------.<<++++[>>+++++++<<-]>>.<---.+++.
Offline Profile Quote Post Goto Top
 
Samael88
Member Avatar

the only thing you need to do is change string into std::string, that will make it work.
and if you want to see your result as the previous poster said, you need to put in the cin.get(); right before the return.

like this:

Code:
 
#include <iostream.h>
#include <string>

int main()
{
std::string mystring = "I am talking to you";
cout << mystring;
cin.get();
return 0;
}


Here is how I got it working. Press retur/enter on your keyboard to get it to quit.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Application Programming Support · Next Topic »
Add Reply

Banner and Logo by TheKeith