English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am newbie in C++ programming.

I am learnging programming in C++. I have read through some websites and books. I thought out the following questions. Please help!

I want to use MS visual C++ to program.
1/ What is the difference between .c and .cpp?
2/ Does the c codes got from the internet work properly in MSVC++?
3/ I saw two different types of pointers: ^ or *. What are the differences?

2007-03-12 23:37:27 · 5 answers · asked by Cloud 1 in Computers & Internet Programming & Design

5 answers

1). .c is the extension for C source code files while .cpp is the extension for C++ source code files. The main difference between C and C++ is that C isn't object oriented while C++ is.
2). Not all of them work on Microsoft Visual C++. If you installed the latest 2005 or 2003 edition, the syntax for it is a bit different (because it only compiles on .NET platform).
3). There are two types of pointers in C++:
- the reference operator (&)
- the dereference operator (*)
The address that locates a variable within memory is a reference to that variable. For example:
int* x;
int y=10;
x=&y; // x will pointer the memory location where y is located.
Using a pointer you can directly access the value stored in the variable which it points to. To do this, you simply have to precede the pointer's identifier with an asterisk (*), which acts as dereference operator and that can be literally translated to "value pointed by".
int *p1,*p2;
*p1=10; //value pointed by p1 is 10
*p2=*p1; //p2 and p2 point the same value
p2=p1; //the pointers are being copied

Hope it helps.. If you have any questions please e-mail me

2007-03-12 23:57:02 · answer #1 · answered by agent-X 6 · 2 0

1) .c is for C language, .cpp is for C++ language, it's just a file extension, there's nothing preventing you from putting C++ compatible code in a .c file and compiling it using a C++ compiler.

2) Usually, code from the internet might need to be modified slightly to work correctly. Sometimes function names change, or OS version changes will cause code to need to be modified to work.

3) * is the standard C / C++ pointer operator. In .net, you can do managed C++ which uses the ^ pointer operator. By default in languages like C# and VB.net, all class instances are actually pointers using the managed pointer operator (^). In traditional C++, you will never use the managed pointer operator because it is .net and Microsoft specific.

2007-03-13 03:41:52 · answer #2 · answered by Pfo 7 · 0 0

The "instruct your self" series by way of Sams Publishing have a tendency to be good introductory texts. i might notice that "instruct your self C" has a 4 famous guy or woman score on Amazon, as an occasion. That stated, i might question if C is the perfect language to income programming in. A language inclusive of Python, Ruby or Java may well be a candidate as they are quite greater friendly languages from a technical perspective.

2016-10-02 01:11:30 · answer #3 · answered by ? 4 · 0 0

I think there is a code in c for dos that don't run in MSVC++

For me it's very hard to code on MSVC++ because if you forgot one code it will display many error which sometimes confused you.

2007-03-13 01:30:15 · answer #4 · answered by Jenna 3 · 0 1

1
.c for c files
.cpp for c++ files
2
you must not find anything wrong, it will work properly
3
i think both are the same

2007-03-13 00:43:42 · answer #5 · answered by abd 5 · 0 1

fedest.com, questions and answers