TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: David Burns
from: Kurt Kuzba
date: 1998-07-10 00:46:30
subject: Beginner`s Questions

DB>   What's VOID used for?
DB>   when I make a MAIN routine, does it have to be VOID?
DB>   will:
DB>   main();
DB>   {
DB>      printf("Hello World");
DB>   }
DB>   work?
   Usually, yes. Void is usually used in C, however. Most
   compilers will assume void if no arguments are listed.
   In C++, void is not necessary. Main should return an int.
   In your example, since no return type is given, it will be
   assigned the default type of int. You will no have control
   of what main() returns in this example without using exit()
   however, since you did not specify a return type. When main()
   returns a value, it returns a DOS errorlevel value, which may
   be used in batch file programming to determine success or
   failure states of program operation.
DB>   do semi colons have to terminate every line that is not a
DB>   { or a } ?
   Every statement terminates with a semicolon.
   Every code block is enclosed in curly braces.
DB>   how do i jump between different procedures?
   Procedures are called functions in C. In your example, you
   'jumped' to the printf() function. You do not move between
   functions, but rather, functions are called in a logical
   progression. The startup code calls main(), whence you may
   call whatever functions are required to accomplish your task.
DB>   Why is '\n' used to stick 's in text?  where does
DB>   this stem from?  are there other such screen-based
DB>   commands that can be put in strings to control text positions?
   These are based on teletype standards. The C language was
   designed to be portable between a large number of platforms.
   The escape sequences assume a minimum output device, lacking
   cursor and color controls, which most compilers provide in a
   machine dependent proprietary library.
   There are:
      '\a' - alarm ( beep! )
      '\b' - backspace ( non-destructive - does not delete )
      '\f' - formfeed ( move to start of next logical page )
      '\n' - new line ( linefeed )
      '\r' - return ( carriage return )
      '\t' - tab ( indents, usually eight or ten spaces )
      '\v' - vertical tab ( moves to next vertical tab line )
   Additionally, certain characters may not appear in a text
   string because they have a meaning, such as the backslash.
   You may put the backslash before them to encode them.
      '\'' - '\"' - '\?' - '\\'
   You may also include numbers in various formats in place of
   the characters themselves. The default is an octal number.
      '\nnn' - this may have up to three octal digits.
   If the '\x' sequence is used, a hexidecimal value follows.
      '\x1b' - this may have one or two hexidecimal digits
   In that example, the character given is ESC, or CHR$(27).
DB>   I can get hold of a copy of Micrsoft C++ V4, but I feel
DB>   this may have this would be too advanced - should I try
DB>   to learn C before trying to learn C++?
   VC++4.0 would be fine, and can be had quite cheaply.
   One can easily compile simple C programs as console apps,
   as well as complex C++ constructs. It also includes extensive
   online documentation.
DB>   as long as a C program is ANSI standard, is the code
DB>   fully portable?  How are O/S and api functions accessed?
   If it is not portable, it is not standard!
   OS and API functions are not standard, except where there are
   standard functions, such as those in stdio.h, which interface
   with the OS and machine specific hardware.
DB>   are there C keywords to access external libraries?
DB>   I thought Header files did this, but they seem only to be
DB>   full of the same C keywords if so, how is the language
DB>   extensible?)
   Did you get my email at all?
   I explained that we build functions, which may be called from
   our programs, and which may be compiled and placed in
   libraries. These libraries have header files, in which the
   prototypes for the functions reside. This allows the compiler
   to know what to expect as a return value and what arguments
   the function requires. It also allows you to define any data
   types or variables required by the library functions.
   Your header files should not, themselves, contain any code.
   Any library function prototyped in a header file is
   immediately accessable to any code in a file in which the
   header file belonging to that library appears in an
   #include  preprocessor command. It is only required that
   the function be prototyped in the text prior to its use.
#include 
int main(void)
{
   puts("Hello World!";
   return 0;
}
   This program does not HAVE any puts() function. It exists in
   the standard io library, and is prototyped in the stdio.h
   file. I was able to use it simply by including the .h file.
   All add-on libraries are accessed in this fashion.

---
> ] Uh-oh... No more treats. Time to learn some new tricks......

---
* 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™.