Absolute Beginner to C - Q's

Started by
16 comments, last by Zahlman 14 years, 10 months ago
Quote:Original post by Zahlman

1) "Advanced" and "easy (to use)"...


...appear. :)


-Ye borland C++ is like Turbo C++ along with many additional programs that help advanced C and C++ programmers. But it doesn't mean I have to be advanced idd, think the author is here to learn me write simple "DOS-based" C programs (whatever that is) rathers then windows programs.

-lol, thats what I needed to hear, my first attempt to learn this book I was searching all the net to learn ANSI C rules xD ofcourse the author is there to do the worrying for me

-Visual C++ is not a compiler? I've never looked at it that way, but it sounds more logical. So Visual C++ is more of a editor then a compiler actually, hehe. BTW the book stated I have to buy a C compiler and talks about bundle of C++/C. Later it states "The most popular C compilers today are Turbo C++ and Borland C++." But reality is you can't really compile with those either? It also mentions Visual C++ btw.

- So I need an compiler without the IDE! this explains it, I can just use notepad to write the stuff and then use compilers to compile it! aha! This is great stuff man

-"This is Microsoft's confused attempt at trying to make a programmer's tool user-friendly, yeah." hahaha I was almost rolling on the floor. lol I forgot we're on da intranetz, anyways :P

-Oh ye I totally understand you about the instict thing, but my first attempt I kind of messed up my whole computer, I'm taking it slow now with this guid from Greg Perry, and taking advice from real life programmers like you as well, its a honor btw, hehe. I actually read the helpmenu first time and I kept reading even tho I didn't understand a thing ^^ was rly fun. I can't wait to look back one day say like wtf this is all so easy. I'll sure master the details aswell I promise.

- So I'll save source code on notepad with "Helloworld.C" if I'm correct, ty thats rly easy, heh

-cool stuff on extensions saving, hehe never have guessed that.

Zahlman, really I appreciate your time very much its been very helpful. thanks bigtime, I've been banging this wall with my head but you just lead me around the corner around the wall. Ty!
Advertisement
Quote:Original post by Joshuad
Just to answer a question...

...Python.


Ye it does make sense, so notepad is like more exact instructions for compilers to compile your cource code into binary states.
And you confirm my thought about just deleting the whole complicated Visual C++ thing since no I know it is "IDE" and just use the notepad, And I'm also going to look into python. rly I should get an absolute beginner guide to programming instead of to C ^^ you guys are all rly helpful, ty Joshuad
I think you misinterpreted some things.

Visual C++ is an IDE. It has an editor, a compiler, a linker, all in one. You can do anything that you need to do in Visual C++, you just have to quit making it seem more difficult than it really is.

You CAN download a standalone compiler, but you are really doing more work then necessary. A good beginners book will first explain the programming process, in terms of what your IDE is doing when you tell it to compile. First, it is taking the source code that you have written, linking the libraries and headers you have used, and compile them into machine language and finally you will have your executable program (.exe). I'm pretty sure I'm missing a few things in there, but I've been awake for nearly a day now, and am about to crash on my desk.

There are BOUND to be some simple tutorials to get you started with Visual C++ 2008 Express around somewhere. Just do a quick search for it, and get started. I wish you the best of luck on day 2, because day 1 was enough to frustrate even me :P
Quote:Original post by twintwix
the book [...] states "The most popular C compilers today are Turbo C++ and Borland C++."

Let me break it to you: your book is OLD.
Quote:Original post by DevFred
Quote:Original post by twintwix
the book [...] states "The most popular C compilers today are Turbo C++ and Borland C++."

Let me break it to you: your book is OLD.


I know, infact the book is 15 years OLD and I'm 17 years young! I wasn't just quoting that because he mentioned those are POPULAR, but because he calls them COMPILERS. And I just read there from replies that Visual C++ isn't a compiler. I'm going to read this topic several times, and follow some instructions here to get my Hello world executable. Hope it works. Again, ty everyone.
If you have Visual C++ installed, then you can use the compiler that comes with it independently. This might help you when learning about how an IDE compiles and links your code, but I wouldn't recommend it when you are trying to write large programs, it is very time consuming.

For example, on my computer (I'm pretty sure I did a fairly typical Visual C++ install) I have a entry in the start menu under Microsoft Visual C++ 2008 Express Edition -> Visual Studio Tools called Visual Studio 2008 Command Prompt. If you have Visual Studio 2005, the entries will be similar.

If I start that, I get a low level command line interface in which I can enter commands to the computer (it looks like a DOS prompt, if you are familiar with these). If I write the command cl, I am manually invoking Microsoft's C++ compiler. I can then pass it different flags and a file name if I want to compile a file.

Here is a command line interaction that produces an executable:
Quote:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files\Microsoft Visual Studio 9.0\VC> cd \

C:\>mkdir test

C:\>cd test

C:\test>notepad main.cpp

C:\test>cl main.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

main.cpp
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : warning C
4530: C++ exception handler used, but unwind semantics are not enabled. Specify
/EHsc
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

/out:main.exe
main.obj

C:\test>main
Hello, World

C:\test>

When you run the command "notepad main.cpp", you must carefully write a correct "hello, world" program or else you will get errors when you try to compile the program.

I wrote a minimal C++ program, but you can write a C program if you wish. If you use the filename "main.c", the compiler will treat the code as C code.
#include <iostream>int main() { std::cout << "Hello, World\n"; }

If you are unfamiliar with these commands, this is a rough translation:
Quote:
computer: you are currently in folder C:\Program Files\Microsoft Visual Studio 9.0\VC\
me: change active folder to C:\
me: make a new folder called "test"
me: change active folder to "test"
me: use the "notepad" program, telling it to use "main.cpp"
<... while I write a program in main.cpp...>
me: compile and link main.cpp
computer: some information about the compile process
me: run the program "main.exe"
computer: the output of "main.exe" is "Hello, World"

You can then remove main.cpp, main.exe and the test folder if you don't want to keep them.

As another example, we can do the compiling and linking steps separately. Instead of running "cl main.cpp", we do:
Quote:
C:\test> cl /c main.cpp

C:\test> cl /l main.obj

The /c and /l mean "compile" and "link" respectively. With a more complex program, you might compile a number of files independently, finally you would link them with a single link command. This point won't feel important now, but the fact that each file is compiled individually and linked later is important in understanding the difference between "compile errors", and "link errors", and also a number of gotchas that occur when trying to build larger programs.

An IDE like Visual Studio manages all this for you, presenting you with buttons like "Build", and "Run". It does all the hard work for you.

Lastly, one reason I am showing you this is to give you an insight into how awkward C++ development is. Modern languages like Python and C# eliminate entire steps of this process.
Quote:
I know, infact the book is 15 years OLD and I'm 17 years young! I wasn't just quoting that because he mentioned those are POPULAR, but because he calls them COMPILERS. And I just read there from replies that Visual C++ isn't a compiler. I'm going to read this topic several times, and follow some instructions here to get my Hello world executable. Hope it works. Again, ty everyone.

Hit up Google for "Thinking in C++" and "C++ A Dialog." They are freely-available online books that are generally considered pretty decent introductions to C++.
Quote:Original post by twintwix
Let me break it to you: your book is OLD.


I know, infact the book is 15 years OLD and I'm 17 years young! I wasn't just quoting that because he mentioned those are POPULAR, but because he calls them COMPILERS. And I just read there from replies that Visual C++ isn't a compiler.

Yep. But Turbo C++ and Borland C++ are. And 15 years ago, they were popular. Things change. :) How did you manage to get your hands on such an old reference, anyway? I hope you didn't pay for it. Did you consider checking the Internet first?

This topic is closed to new replies.

Advertisement