hello again

i have mac computer and i have xcode on it. i am looking for some use full beginners books or tutorials. Right from start i have no previous knowledge of c++. can any one suggests any book for site for beginners which specially deal with g++ and xcode.
thankyou

The documentation will be your best bet for learning your particular implementation. For learning C++, you would be wise to stick to books that follow the standard language closely. "Accelerated C++" is a good choice.

Read the Read Me threads at the beginning of this board because they contain a wealth of information about books, compilers and other related resources.

thanks for advice
i tried very basic program with Xcode which is like this

#include "hello5.h"
#include "iostream"
using namespace std;

int main1()
{
cout <<"welcome";
return 0;
}

build is successful but when i "Run" it opens only a blank screen without displaying welcome which i am expecting.
i don't understand where i am going wrong.

You don't need #include "hello5.h" do you?

int main1() should be int main() but as the poster above me stated that particular include file is not necessary. Also, #include "iostream" should be #include <iostream> Quotes are generally used to reference headers that require an absolute path or headers in your project.

now i remove #include"hello5.h" and i change to #include<iostream> still same blank screen. As shawn suggested when i change int main1() to int main()
this error message it giving thats why i changed to to int main1() before to bypass. error message is
Line Location Tool:0: Command /Developer/usr/bin/g++-4.0 failed with exit code 1
Line Location Tool:0: duplicate symbol _main in /Users/harpreetsingh/hello5/build/hello5.build/Release/hello5.build/Objects-normal/i386/hello5.o and /Users/harpreetsingh/hello5/build/hello5.build/Release/hello5.build/Objects-normal/i386/main.o
Line Location Tool:0: Command /Developer/usr/bin/g++-4.0 failed with exit code 1
Line Location Tool:0: duplicate symbol _main in /Users/harpreetsingh/hello5/build/hello5.build/Release/hello5.build/Objects-normal/ppc/hello5.o and /Users/harpreetsingh/hello5/build/hello5.build/Release/hello5.build/Objects-normal/ppc/main.o

any help is appreciated
thank you

>>Quotes are generally used to reference headers that require an absolute path or headers in your project
Most (but not all) compilers use angle brackets to reference header files that are in the compiler's known directories, such as the compiler's include directory and double quotes are used to reference all other header files, such as those you write yourself and are in your project's source code directory. On the otherhand, I have used compilers that treat angle brackets and quotes the same.

>>duplicate symbol _main
you are getting a blank sceen because there were compile errors. You can not execute the program until after your compiler produces 0 errors and links successfully.

If you get that error message then you are not posting your entire program. You can have only one main() function in a program -- actually that really applies to every function that have the same list of parameters.

thanx for quick response dragon this what i did when i opened new project. after clicking on "new project" i selected "carbon c++ standard application" and name the project. [i tired it with carbon c++ application too} then and open new file and selected "C++ file" from assistant window and wrote that program.
[ i am using Xcode]

thank you

compile was successful with 0 errors

compile was successful with 0 errors

Great going! :) Now you should see the correct output on the screen.

i know it is so frustrating. but i am having same damn blank screen even after Build was successful and compile errors 0

>>i am feeling dumb
Don't feel too bad -- we all go through that learning curve.

Please post your most recent code. You probably need to add a line at the bottom of main() just before return to make it wait for you to see the output.

int main()
{
...
   cin.get(); // get key 
   return 0;
}

this is the recent code i am trying to "Run"

#include <iostream>
using namespace std;

int main()
{
cout <<"welcome";
return 0;
}

But with same error message about "int main()"

This is code with successful Build and 0 error messages

#include <iostream>
using namespace std;

int mainfunction()
{
cout <<"welcome";
return 0;
}

And i tried this code as well

#include <iostream>
using namespace std;

int mainfunction()
{
cout <<"welcome";
cin.get();
return 0;
}

producing same blank screen.

i am suspecting that something is wrong with creating new project and new file. just a hunch
thank you for your enormous help

int main() is the correct entry point.

>duplicate symbol _main in...

You probably just need to clean your build (remove all those object files ie *.o - look for or create a 'clean' rule in your makefile if using one or a 'clean' option in whatever ide you're using) and then rebuild - your linker is possibly just getting confused with an earlier object. Make sure you comment out or remove all the other superfluous code before rebuilding, ie your source file should only contain:

#include <iostream>
using namespace std;

int main()
{
cout <<"welcome";
return 0;
}

Thanx Comrade
i did tried as u suggested clean the build and build again. i am getting following error message

Line Location Tool:0: Command /Developer/usr/bin/g++-4.0 failed with exit code 1
Line Location Tool:0: duplicate symbol _main in /Users/harpreetsingh/hello1/build/hello1.build/Release/hello1.build/Objects-normal/ppc/firstprogram.o and /Users/harpreetsingh/hello1/build/hello1.build/Release/hello1.build/Objects-normal/ppc/main.o


if i change it to int mainfunction() it seems everything works just fine no error message and build successful but it producing blank screen.

as Comrade Ogilvy said :: int main(void) is the correct entry point. I don't know the ide you are using but from the output you posted it seems that you have 2 object files {firstprogram.o and main.o} which i guess that derive from 2 source files {firstprogram.c and main.c}... and in both source files you have a main function which is wrong{you can't have more than one entry point in your program}... so try to delete one of the .c files and in the other one paste this code::

#include <iostream>
using namespace std;

int main()
{
    cout <<"welcome";
    return 0;
}

ps:: if this is the first time you are programming maybe you shouldn't start with an IDE but compile from the command line....
To do so use g++ your_file.c -o your_program where your file is the input file {i.e main.c -- you can write this file with a text editor} and your_program is the name of the executable {could be runMe or whatever you want}...
To run your compiled program type: ./your_program hope i helped
-nicolas

Thanks Nicolas

It really helped and lead me to fix the problem. Now everything is working fine. I was creating project at wrong place. it was like 1st grade kid try to work with post graduate books. Now i move to command line utility and it worked.
Thanks everyone who took time to help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.