TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: David Burns
from: Kurt Kuzba
date: 1998-07-16 01:03:18
subject: Beginner`s Questions

DB> SA> void main() return nothing.
DB> SA> int main() returns an int.
DB> SA> char main() returns a char.
DB> SA> char *main() returns a pointer to a string.
DB>   When you say it returns nothing, how do a make a procedure
DB>   return something and how do i access that returned value?
   You make a FUNCTION return something by prototypeing as
   returning something and then using the return statement.
int add_ints(int a, int b)
{
   return a + b;
}
   This returns an int value.
DB>   Can you explain the use of '*' in variables?
   The asterisk is used with pointer variables. A pointer is a
   variable which is an address to a specific place in memory.
int my_int = 7, *pointer_to_int = &my_int;
   In this example, I create an integer and an integer pointer.
   I initialize the integer with a value, and initialize the
   pointer with the address, ( &my_int ), of my integer
   variable. I may now access the memory location at which the
   data for my_int resides by means of dereferencing that
   address, which is done with the '*'.
printf("my_int = %d\n", *pointer_to_int);
*pointer_to_int = 15;
printf("my_int = %d\n", my_int);
   This will print the value of seven, then update the value to
   15, and print it out again, using the ordinary variable name.
   I suggest you get a copy of SNIPPETS and read the pointer
   tutorial found therein.
DB> SA>   Turbo C/C++ 3 for DOS is /excellent/ to learn with -
DB>   Where can I get it from?  Can I freq it from you?
   It's a commercial program, unfortunately.
   There are many low-cost compilers available, however, as well
   as DJJP, which is NOT a commercial program, and may be
   obtained easily from many BBS's and the Web.
   Switching to LINUX will also get you a free C/C++ compiler.
   Most C++ compilers do both C and C++.

> ] Those who don't learn from the past are... Rats! I forgot...

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728
SEEN-BY: 639/252 670/213 218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.