PDA

View Full Version : Compile with math.h,


i.mehrzad
August 19th, 2008, 03:09 PM
How do i cmpile when i have #include<math.h>. Talking about C, and compiling with gcc.

How do you compile with getch(), and clrscr() functions used. It does not compile by the simple technique i know.

gcc 123.c -o 123
./123
This is what i use. Any additions for the above programs to work???

LaRoza
August 19th, 2008, 03:12 PM
How do i cmpile when i have #include<math.h>. Talking about C, and compiling with gcc.

How do you compile with getch(), and clrscr() functions used. It does not compile by the simple technique i know.

To use math.h you have to use the "-lm" flag.


gcc -lm ...


getch() and clrscr() are DOS specific and are not cross platform.

If you have to use them, you can use getchar() and system("clear") in their place then switch them out when you are submitting it.

You could use other libraries like ncurses, but that would be overkill and not worth it (because your instructor will be using Windows and the tasks are simple)

i.mehrzad
August 26th, 2008, 01:41 PM
getchar() and getch() are not the same.

Suppose i want to enter onto the screen such that i get stars displayed(much like what we do when we enter our email id's), there getchar will not work. I have to use getch. How is it done???

i.mehrzad
August 26th, 2008, 10:26 PM
If conio.h is not a standard library on linux, then where do i get all the functions that conio.h has in my program?

Are these headar files valid on linux machines:
ctype.h
math.h
stdlib.h
string.h
graphic.h
time.h

Are there any differences when compiling for these header files?
I know that for math.h we use the -lm options as well. What about the others.

WW
August 27th, 2008, 12:02 PM
Are these headar files valid on linux machines:
ctype.h
math.h
stdlib.h
string.h
graphic.h
time.h

All except graphic.h are standard.

Are there any differences when compiling for these header files?
I know that for math.h we use the -lm options as well. What about the others.
Except for math.h, which requires -lm, no special compiler options are needed when you use the standard headers and libraries.

y-lee
August 27th, 2008, 12:22 PM
If conio.h is not a standard library on linux, then where do i get all the functions that conio.h has in my program?

I have saw this question several times on various forums and looked around and found a Linux "conio.h" (http://www.gerald-friedland.de/projects_old.html). I have not had a chance to use this or test it so I do not know how well it works.

i.mehrzad
August 27th, 2008, 04:10 PM
what do i do in the case of graphic.h?