i have two questions,please dont tell me that i violate dani web ruls because of my long
questions thank u.

one:
i wrote a program in c,and i compiled it(in borland c),it had no errors(so far so good)
then i run it and errors such as:
linker error:undifined symbole_line in module
came up,now[waht can i do(britney spears] .
in bellow are some parts of my program.(sperate parts)

#include <graphics.h> 
...................................................                                                        
¦   setcolor(RED);                                                        
¦        line(0,0,620,0);                                                      
¦        line(0,0,0,470);                                                           
¦                                                          
¦                                                                              
¦                                                                              
¦int gm=DETECT,gd;                                                             
¦void  main(){                                                                 
¦        initgraph(&gm,&gd,"d:\\newfol~1\\borlandc\\bgi");                     
¦  
+-[¦]------------------------------ Message -----------------------------1-[?]-+
¦ Linking NO.EXE:                                                              ?
¦ Linker Error: Undefined symbol _line in module NO.CPP                        ¦
¦ Linker Error: Undefined symbol _setcolor in module NO.CPP                    ¦
¦ Linker Error: Undefined symbol _circle in module NO.CPP                      ¦
¦•Linker Error: Undefined symbol _initgraph in module NO.CPP                   ¦

and the other question.

#include<stdio.h>
void main (){
clrscr();

 gotoxy(50,20);//one
 printf("*");

 gotoxy(0,0);//two
 printf("*");

 getch();
 }

when i wrote this program,it printed two stars next to each outer in the end of page
then i changed the place of two gotoxy and,program wrote them in right place?!!

thnx a lot.

Well for one change your extension from .cpp to .c, since there's no other way for the compiler to know if it's compiling C or C++ code (except maybe a parameter).

please dont tell me that i violate dani web ruls because of my long
questions thank u

long questions are fine

a) the code in your first bit is just loose. put it in the main.
b) use .c
c) in future use CODE tags, not using them IS against the rules

i have two questions,please dont tell me that i violate dani web ruls because of my long
questions thank u.

As jbennet said, long Q's are fine, but your title is a violation. See the rules.
Sorry, you asked for it. :icon_twisted:

and the other question.

#include<stdio.h>
void main (){
clrscr();

 gotoxy(50,20);//one
 printf("*");

 gotoxy(0,0);//two
 printf("*");

 getch();
 }

when i wrote this program,it printed two stars next to each outer in the end of page
then i changed the place of two gotoxy and,program wrote them in right place?!!

See this about void main() If memory serves, [0,0] is not the upper left corner. Check your documentation. And did you specify the header file defining all those special Borland-only functions?

yeah main() should return an int (0 for sucessful execution?) - windows doesnt mind but its the standard and on UNIX systems it will be logged as an error.

There are interesting sentences about main in the C++ and C standards.
C++:

An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main:
int main() { /* ... */ }
and
int main(int argc, char* argv[]) { /* ... */ }
...
If control reaches the end of main without encountering a return statement, the effect is that of executing
return 0;

The C Standard corresponding requirements:

The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no
parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names may be
used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;9) or in some other implementation-defined manner.

Implementation-defined term means (apart from anything else) that the implementation shall document this issue.

Pay attention to "but otherwise its type is implementation-defined" and "or in some other implementation-defined manner" clauses...
Any comments?..

>Pay attention to "but otherwise its type is implementation-defined"
>and "or in some other implementation-defined manner" clauses...
>Any comments?
I always have comments. Let's break it down because you've quoted two separate things. The first quote is a slice of the following sentence from the C++ standard:

It shall have a return type of type int, but otherwise its type is implementation-defined.

The type of a function is the combination of return type as well as the type and number of parameters, so this quote says that the return type must be int, but the implementation is free to support parameter lists above and beyond the required two. Without this loophole, extensions like the third envp parameter would become undefined.

The second quote is probably what you were referring to as it refers to main as a whole and can be applied to void main as a specific case:

or in some other implementation-defined manner.

This is where the C standard says that implementations are free to support any type of return value or any type and number of parameters as long as those choices are documented.

If you want to be strictly correct, C allows void main as a valid extension but such an extension in C++ is non-standard because the same loophole doesn't exist. In C++ and the case where the compiler doesn't support the definition of main that you use in C, the behavior is undefined based on "The Shall Rule".

The Shall Rule: When the standard says you "shall" or "shall not" do something, failure to follow that advice results in undefined behavior.

Narue, thank you for clarification of C++ standard sentence. I don't understand that otherwise means "in other respects" there.
The 2nd part (about main returned value type in C) is exactly the same as I want to accentuate: stop Holy War on void main in C, don't refer to C++ rules in C (and don't use void main in your programs ;) ).

This article has been dead for over six months. Start a new discussion instead.