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

the_conqueror

Ambassador of Buzz
I have a few questions :
How much time would I require to learning the basics of C ?
Can I switch to C++ after that ? Would it be harmful if I step on C++ directly without learning C ?
Please suggest a book of C and C++ with all the beginner stuff.

PS-please go through my previous posts before answering so you can understand my situation.
 
OP
Liverpool_fan

Liverpool_fan

Sami Hyypiä, LFC legend
1. As much time as basics of C++ will.
2. No. Particularly the way C++ is set in Indian education, it is basically outdated C programming in C++ with classes.
3. You've been recommended already. But I'll say again: The C Programming Language and Head First C both. You don't need to complete both books either just go as far as you can. For C++, then continue with Thinking in C++.
 

bijay_ps

Broken In
I wrote a simple hello world program but not stored it in Ubuntu's home directory, instead i stored it in one of the windows drive. (I am using ubuntu 12.04 alongside of windows)When I compiled the program it worked just fine but when I tried to execute it I got an error message "Permission denied". And When I store the program in Ubuntu's home directory I can perfectly compile and execute the program. So please tell me how to overcome this problem??

I even tried sudo command, but it didn't helped
 
Last edited:

nims11

BIOS Terminator
you need to make the compiled file executable, do this by
Code:
chmod +x a.out

if you want the compiled file to be always executable, then in /etc/fstab, add an entry for your windows drive like this
Code:
/dev/sda2 /media/xyz ntfs defaults,ntfs-3g,user,exec 0 1
 

Baker

Albicelestes
need to install gcc on my suse 10..... tell me where i can down load the package and how to install
 
OP
Liverpool_fan

Liverpool_fan

Sami Hyypiä, LFC legend
need to install gcc on my suse 10..... tell me where i can down load the package and how to install
Mentioned in the OP.

OpenSUSE

Open YAST. Go to Software Management.
Change the Filter to 'Patterns' and select C/C++ Compiler and Tools.
Click Accept. And install.

And why are you using SuSE 10? That thing is old.
 

cyber

my name defines me
c program error

Code:
#include<stdio.h>
typedef struct uttam
{
        int a;
        struct uttam *next;
}test;
main()
{
test c1,*p;
p->a=2;
printf("%d",p->a);
}

~
~
~
~
when i run the program it says segmentation fault...:-(
 

gforz

Maximum GAME
Re: c program error

In your case,the pointer p is a variable of struct uttam "aliased" by test.
Problem is this pointer doesnt point anywhere and the moment you try to access the member of the struct using this pointer ,it throws segmentation error.
Using typedef ,you cannot assign any address "In this case" ,AFAIK.

So "in this case",the code would be:

#include<stdio.h>
struct uttam
{
int a;
struct uttam *next;
}test;
main()
{
struct uttam c1,*p;
p=&test;
p->a=2;
printf("%d",p->a);
}

hope this helps:razz:


It should work with typedef:

In your code:

p=(test*)malloc(sizeof(test));
 
Last edited:

x64

loves linux
Anything with which you are comfortable with.

Eclipse, Netbeans and Microsoft Visual C++ are excellent. But many of their features are unnecessary if you are only into basic programming.

Dev C++ comes with an old version of MiniGW by default.

I find Code::Blocks to be the best IDE for me as a basic programmer. It is very simple yet very efficient IDE for C/C++
 

krazylearner

poor little me
Re: c program error

segmentation fault comes when you try to access invalid memory or the memory which doesn't exist in your program yet.

in your code you have not initialized the pointer p with address of some memory location .

Try to initialize p pointer with malloc or new before using it to access a memory location and your code will work fine.
 

krazylearner

poor little me
Re: c help

"programming in c" by kernighan and Ritchie is a good book .

But according to my experience indian writers like yashwant also has good expertise in this subject but sometimes they mess up with the basic concepts.So choose wisely .:oops:

for compiler i would recommend you to go with bloodshed dev c++ .For beginners it is best gui based compiler and is integrated with almost every feature.

installing ubuntu will be a trouble for you if you are a windows user which you are .
 

nbaztec

Master KOD3R
Re: c program error

segmentation fault comes when you try to access invalid memory or the memory which doesn't exist in your program yet.

in your code you have not initialized the pointer p with address of some memory location .
This.

Try to initialize p pointer with malloc or new before using it to access a memory location and your code will work fine.
new operator is specific to C++
 

nbaztec

Master KOD3R
Re: c help

"programming in c" by kernighan and Ritchie is a good book .

But according to my experience indian writers like yashwant also has good expertise in this subject but sometimes they mess up with the basic concepts.So choose wisely .:oops:

for compiler i would recommend you to go with bloodshed dev c++ .For beginners it is best gui based compiler and is integrated with almost every feature.

installing ubuntu will be a trouble for you if you are a windows user which you are .

I suggest you read the C/C++ Beginner Thread before suggesting a compiler which has had no new official release since 2005, over Code::Blocks, Eclipse or even a simple GEdit/Notepad++ ; and thinking that Yashwant Kanetkar has expertise in C in spite of the fact that his Let Us C is a waste of our natural resources.

@OP Just use gcc as the compiler collection and you'd be fine with any text-editor/IDE.

MOD EDIT: Threads merged.
 

rahul_c

Journeyman
I'm a newb in the programming arena :), just joined a 4 yr (classes not started yet) CSE course. I have some queries:

> What books should I buy for C (first yr course only has C), giving that I've no experience of programming what so ever?

> Which compiler is the best, I've turbo C but it does not work in windows 7? Even though its not recommended everyone still uses it! :|

> How long does it take to reach a level where I can develop my own apps from the scratch? I mean proper GUI apps.

> Do programmers require powerful PCs, I have a old 3 yr laptop (Dell Vostro 1510) would this suffice?

> A silly one: If one wants to learn everything about programming how long is it gonna take? I don't want C/C++ can never be learned entirely crap!
 

nbaztec

Master KOD3R
> What books should I buy for C (first yr course only has C), giving that I've no experience of programming what so ever?
Read the starting threads it has aplenty suggestions on the likes of Kernighan & Ritchie. Just don't go for Indian authors.

> Which compiler is the best, I've turbo C but it does not work in windows 7? Even though its not recommended everyone still uses it! :|
Use gcc. Avoid TC at all costs.

> How long does it take to reach a level where I can develop my own apps from the scratch? I mean proper GUI apps.
Depends on you.

> Do programmers require powerful PCs, I have a old 3 yr laptop (Dell Vostro 1510) would this suffice?
No. Only determination.

> A silly one: If one wants to learn everything about programming how long is it gonna take? I don't want C/C++ can never be learned entirely crap!
No programming language can ever be learned entirely. If it can, it might as well cease to exist.
 

rahul_c

Journeyman
Read the starting threads it has aplenty suggestions on the likes of Kernighan & Ritchie. Just don't go for Indian authors.

Use gcc. Avoid TC at all costs.

No programming language can ever be learned entirely. If it can, it might as well cease to exist.

So the 'can never learn C/C++ entirely' is true, just sounded bull when seniors from college say it.

I'm buying these books: C Programming Language by Kernighan & Ritchie (The Bible :mrgreen:) and Head First C#.

Too bad about the computer though, now need a new reason to tell dad for buying a powerful PC. :-(

For compilers I'm going to use either code::blocks or GCC, gotta try them both.
 
Top Bottom