C/C++ Beginner's Guide and Post Basic Questions here

the_conqueror

Ambassador of Buzz
^ I knew that already bro, and even tried that once, didn't work. I wasn't in a mood of typing so picked up an old file lying around. See what happens when I try it your way:

*i.imgur.com/fnfxh.png
 

nims11

BIOS Terminator
^^ goto Settings-> compiler and debugger, select GNU GCC compiler (if not set), then under the toolchain executable tab, make sure the path to the compiler installation is correct. eg, mine is "C:\Program Files (x86)\CodeBlocks\MinGW"
 

rajatGod512

N00B Troller
^^ Sorry ... I was in a hurry :-(

^ I knew that already bro, and even tried that once, didn't work. I wasn't in a mood of typing so picked up an old file lying around. See what happens when I try it your way:
On CodeBlocks FAQ I got this :
Q: My simple C++ program throws up lots of errors - what is going on?

If you have a C++ program like this:

#include <iostream>
int main() {
std::cout << "hello world\n";
}

and when you compile it you get errors like this:

fatal error: iostream: No such file or directory

then you have probably given your source file a .c extension. If you do that, the GCC compiler (and others) will probably attempt to compile the file as a C program, not as C++. You should always give your C++ source files the extension .cpp to make sure the compiler handles them correctly.

also try and save the .cpp file in the same directory where you have installed mingw/Codeblocks. See if it works
 

chavanshashank

Right off the assembly line
Hey please help me to solve this question. Can anybody give me the source code which is executing and giving right output.
Shown in question below.? I am using DEV C++ and TURBO C 5.5 for compiling.

*Spaceman Spiff

Our super-hero, the fearless Spaceman Spiff, finds himself on the
planet closest to Star X-35 in his quest to wipe out the evil, vicious,
flagitious, heinous alien species that threatened to invade our planet! An
alien approaches...But in the blinding light, our hero can hardly make out
if its hostile. By the way it attacked Spiff's spaceship, he definitely was
hostile!
Spaceman Spiff, captured by vicious Zogwargs, is about to be
transported to the labor camp! But our hero hatches a bold plan!
At the last second, Spiff makes a break! Taking advantage of the planet's
weaker gravity, our hero is away like a shot... towards the infinite galaxy.
Finally away from the planet, only after planting a bomb powerful
enough to eradicate the entire Zogwargs species, Spiff wanders around,
head held high in victory. But wait, what does he notice? His star-o-meter showed him Star X-35's close and strange position relative to Star
Y-40!
He found that the level of a star was an amount of the stars that are
not higher and not to the right of the given star. He wanted to know the
distribution of the levels of the stars.
5
*
4
*
1 * 2 * 3

For example, look at the screenshot of Spiff's space-o-meter. Level of the
star number 5 is equal to 3 (it's formed by three stars with a numbers 1, 2
and 4). And the levels of the stars numbered by 2 and 4 are 1. At this map
there are only one star of thelevel 0, two stars of the level 1, one star of
the level 2, and one star of the level 3.
You are to write a program that will count the amounts of the stars of
each level on a given map and help Spaceman Spiff in cracking the code!
Input
The first line ofthe input contains a number of stars N (1 = N = 15000).
The following N lines describe coordinates of stars (two integers X and Y
per line separated by a space). There can be only one star at one point of
the plane. Stars are listed in ascending order of Y coordinate. Stars with
equal Y coordinates are listed in ascending order of X coordinate. Output
The output should contain N lines, one number per line. The first line
contains amount of the level 1 and level N-1.
Example Input: 5
1 1
5 1
7 1
3 3
5 5
Output: 1
2
1
1


Please reply.! Thanks.
 

TheSloth

The Slowest One
hi, i am new to open Source world. Using Fedora 17. I tried to install gcc complier given on first page, somthing started to download and then a error came like " Mo mirror to try".I need compilers of c and c++ urgently.I have Win7 too and tried in that too but failed there also. But first i want compilers in Linux
 

TheSloth

The Slowest One
For windows i tried doing things given on first page but i don't understand the problems i am facing. Infact I didn't understand things i was doing. I installed MinGW then set variable path to something something then tried compiling a cpp program but "command not found".
 

ud0103

Show Time!
I installed codeblocks with the MinGW compiler. Ran it and selected gcc as the default compiler. When I run a C program , it runs fine. But a C++ program gives error that iostream not found. How can an important header file appear missing in library. Whats going wrong ?

Try this code:-

using namespace std;
#include<iostream>

int main()
{
cout<<"Hello!";
}

Good Luck!
 

abhijangda

Padawan
hi, i am new to open Source world. Using Fedora 17. I tried to install gcc complier given on first page, somthing started to download and then a error came like " Mo mirror to try".I need compilers of c and c++ urgently.I have Win7 too and tried in that too but failed there also. But first i want compilers in Linux
This error occurs, when yum is not able to connect to any of the mirrors available in list.
If you have any proxy settings then add them in /etc/yum.conf file.
 

SlashDK

MV VIP to the MAX
Hi people,

I need help installing GCC for practicing c++ for Indian Olympiad of Informatics. I already have vc++ but GCC is the official compiler. I tried to follow the instructions at Installing GCC - GNU Project - Free Software Foundation (FSF) but failed miserabely at every step :D Is there any automated installer for GCC for c++? (I havn't been able to find any).

EDIT: For Windows.

EDIT: Finally found a preper tutorial on youtube. Downloading from Codeblocks with MinGW now
 
Last edited:

RBX

In the zone
C was first semester subject, but I didn't buy a book and never actually learned it, somehow passed with lab knowledge (with Turbo C).
So, now I'm looking to formally learn it with a book that illuminates most aspects of C language - not looking for an introduction to programming book, neither a very old book.
So could anyone suggest a book that gives detailed knowledge of pointers, typedef etc with illustrations and follows at least C99 ?
 

krishnandu.sarkar

Simply a DIGITian
Staff member
C was first semester subject, but I didn't buy a book and never actually learned it, somehow passed with lab knowledge (with Turbo C).
So, now I'm looking to formally learn it with a book that illuminates most aspects of C language - not looking for an introduction to programming book, neither a very old book.
So could anyone suggest a book that gives detailed knowledge of pointers, typedef etc with illustrations and follows at least C99 ?

Go for Head First C. You'd enjoy the learning with Head First
 
Wrote my first program today. :hyper:. It was the same Hello world as given on the firsr page. Can anyone post some more basic programs like that?? Or better suggest a book that begins from root level.
 

vickybat

I am the night...I am...
I'd like to disagree. The book is not for someone who is about to start his programming journey.

Why not mate ? Can you please justify?

Head first series has helped me a lot and i was a complete noob in programming. I've read "head first java", "head first sql" , "head first html5" and i was completely new to those technologies.
Those books gave me a broad understanding of various concepts and head first c should be no different.

That is miles ahead than books like venugopal, yashvant kanetkar and the likes that most students read.
 

dashing.sujay

Moving
Staff member
Why not mate ? Can you please justify?

Head first series has helped me a lot and i was a complete noob in programming. I've read "head first java", "head first sql" , "head first html5" and i was completely new to those technologies.
Those books gave me a broad understanding of various concepts and head first c should be no different.

That is miles ahead than books like venugopal, yashvant kanetkar and the likes that most students read.

There's a difference between a noob programmer and a starter programmer. One is acquainted enough but unclear, one is in complete darkness. Head first C is a but high level for latter.
 
Top Bottom