printf("\n\nFibonacci-Numbers\n\n");
int a = 0;
int b = 1;
int i;
int x;
printf("%d ", a );
printf("%d ", b );
while(b<5000)
{x = a;
a = b;
b = x + b;
printf("%d ", b);
}
printf("\n\n"); system("PAUSE");
}
Thanks for now.....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"clrscr(); exists in C. It is defined in 'conio.h'. It works perfectly fine in Turbo C and Turbo C++, Borland C++. It doesn't work in Dev C++.I dont know why."
Just because it works in Borland compilers doesn't mean it's part of the C language. Dev uses the GCC compilers which pretty much sticks to standard C/C++
You can search the forum for clrscr to find some alternatives, this subject comes up quite often.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'conio.h' is DOS console library. If you want to use its function in Dev-c++ with mingw32 (which is not DOS compiller at all) you must use other similar library, for example use something from here: http://devpaks.org/list.php?category=Text%20console
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-11-26
Note that Dev-C++ using GCC as its compiler has little (in fact nothing) to do with what libraries are available. The compiler (and the C language) and the libraries are distinct. The MinGW distribution of GCC utilises the MSVCRT.DLL that is installed with Windows. So you need to reference Micosoft's documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/crthm.asp.
If you want to know what is in the standard library, and therfore generally provided with all compilers check http://www.cppreference.com/
The Microsoft C library is a superset of the standard library.
Console I/O is not standard (except for the basic TTY style services provided by stdio) because systems have varying console capabilities, and the standard must run on all systems. In Win32 there is a console API, that will work with any Win32 compiler. Conio is a hangover from DOS, and even then Microsoft and Borland's conio libraries differed significantly. It is best forgotten unless you realy need to port legacy code. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_reference.asp for the Win32 API.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2004-11-26
... and...
You should always include the headers for the libraries you are using. That way errors can be detected by the compiler rather than the linker. The linker can only tell if a symbol you have used does not exist, whereas the compiler can check that you have used the correct number and types of parameters.
If you include headers for libraries other than the standard library, then you also have to explicitly link the associated libraries.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
clrscr(); exists in C. It is defined in 'conio.h'. It works perfectly fine in Turbo C and Turbo C++, Borland C++. It doesn't work in Dev C++.I dont know why.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
clrscr() is not a standard C or C++ library function.
conio.h is not a standard C or C++ header file.
You need to know which libraries are standard and which are not. Many compilers have header files, functions, and libraries that are not standard. Ususally, the non-standard stuff is a small subset of the libraries shipped with a compiler.
The gcc family of compilers is available on an extremely wide range of platforms for an extremely wide range of processors. It tries to be a portable as possible, so it tends to avoid including non-standard libraries.
You can google for clrscr() replacements.
A common one is
system("clrscr");
rr
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
no, you should never #include a c or cpp file, they're not meant to be included!
it is a really evil thing to do
(ask if you want more details)
instead, you should either include that file in the project, or link the corresponding object file or library if you have it (if you don't have it, you can make it)
anyway, Dev-C++ 4.9.9.0 (with MinGW) doesn't come with a conio.c (and its conio.h lacks most conio functions), and if you get the conio package from my web site then you get a library that you can link, and clear instructions
Adrian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
textcolor() does not exist in Dev-cpp and for some reason, the cprintf() is declared as _cprintf() and I think the funtion is defined in <conio.h> but I am not sure.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi...im new on C and i use Dev-C++ cause its nice
and not so big like c++ builder 6.
I have problem, for example this src.
While compiling to an EXE i get many errors, so what is wrong here, do i need some plugins ?
// #include
void main(void)
{clrscr();
textcolor(3);
cprintf("IDE-INFO v1.00\r\n\r\n");
}
Thanks for now.....
"clrscr(); exists in C. It is defined in 'conio.h'. It works perfectly fine in Turbo C and Turbo C++, Borland C++. It doesn't work in Dev C++.I dont know why."
Just because it works in Borland compilers doesn't mean it's part of the C language. Dev uses the GCC compilers which pretty much sticks to standard C/C++
You can search the forum for clrscr to find some alternatives, this subject comes up quite often.
See also (if you want):
http://www14.brinkster.com/aditsu/dev-cpp-faq.html#conio (providing an alternative)
http://ma.rtij.nl/acllc-c++.FAQ.html#q4.2
http://www.comeaucomputing.com/techtalk/#clearscreen
(both providing some explanations)
'conio.h' is DOS console library. If you want to use its function in Dev-c++ with mingw32 (which is not DOS compiller at all) you must use other similar library, for example use something from here:
http://devpaks.org/list.php?category=Text%20console
Note that Dev-C++ using GCC as its compiler has little (in fact nothing) to do with what libraries are available. The compiler (and the C language) and the libraries are distinct. The MinGW distribution of GCC utilises the MSVCRT.DLL that is installed with Windows. So you need to reference Micosoft's documentation at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/crthm.asp.
If you want to know what is in the standard library, and therfore generally provided with all compilers check http://www.cppreference.com/
The Microsoft C library is a superset of the standard library.
Console I/O is not standard (except for the basic TTY style services provided by stdio) because systems have varying console capabilities, and the standard must run on all systems. In Win32 there is a console API, that will work with any Win32 compiler. Conio is a hangover from DOS, and even then Microsoft and Borland's conio libraries differed significantly. It is best forgotten unless you realy need to port legacy code. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_reference.asp for the Win32 API.
To see how clear screen can be implemented using the console API see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/clearing_the_screen.asp.
Clifford
... and...
You should always include the headers for the libraries you are using. That way errors can be detected by the compiler rather than the linker. The linker can only tell if a symbol you have used does not exist, whereas the compiler can check that you have used the correct number and types of parameters.
If you include headers for libraries other than the standard library, then you also have to explicitly link the associated libraries.
Clifford
First, why is your #include in comment ? You usually need to include headers (like <iostream>, <cstdio>) for your program to work.
The printf() function for example is declared in <cstdio> ; cprintf() in <conio.h> ; clrscr() doesn't exists in C++, just in Pascal.
The main function must return an integer. Both following declarations are accepted by the compiler :
int main(void) ;
int main(int, char **) ;
textcolor() will surely need a little #include too...
Georhan
Hi Georhan......
i comment #include, cause i though i don't need it...
now i'd change the first lines like this:
include <stdio.h>
include <io.h>
include <stdio.h>
int main(void)
{//clrscr();
textcolor(3);
cprintf("Test\r\n\r\n");
.....but i get the same errors
[Linker error] undefined reference to
textcolor' [Linker error] undefined reference to
cprintf'....so what kinda #include do i need to put some color in my text ?
clrscr(); exists in C. It is defined in 'conio.h'. It works perfectly fine in Turbo C and Turbo C++, Borland C++. It doesn't work in Dev C++.I dont know why.
To reinforce what black_adder said ...
clrscr() is not a standard C or C++ library function.
conio.h is not a standard C or C++ header file.
You need to know which libraries are standard and which are not. Many compilers have header files, functions, and libraries that are not standard. Ususally, the non-standard stuff is a small subset of the libraries shipped with a compiler.
The gcc family of compilers is available on an extremely wide range of platforms for an extremely wide range of processors. It tries to be a portable as possible, so it tends to avoid including non-standard libraries.
You can google for clrscr() replacements.
A common one is
system("clrscr");
rr
I think you meant:
system("CLS");
There is not clrscr command, at least not on my system. Note it will compile with just about anything in the "system", I even put in
system("waynesaputz");
and it compiled (truth compiles you know), but you will get a run-time error. (A non-crashing run-time error - which is cool to me)
Wayne
Your right.
sigh. Careless errors in 2 posts in 2 days. sigh.
rr
At this rate, you will catch up to my total errors in the year 5454!
:)
Wayne
If you do a
include <conio.c>
instead of <conio.h> then clrscr() will work.
I think it is a problem with the linker. It either cant
find the object code for clrscr() or it does not exist.
no, you should never #include a c or cpp file, they're not meant to be included!
it is a really evil thing to do
(ask if you want more details)
instead, you should either include that file in the project, or link the corresponding object file or library if you have it (if you don't have it, you can make it)
anyway, Dev-C++ 4.9.9.0 (with MinGW) doesn't come with a conio.c (and its conio.h lacks most conio functions), and if you get the conio package from my web site then you get a library that you can link, and clear instructions
Adrian
textcolor() does not exist in Dev-cpp and for some reason, the cprintf() is declared as _cprintf() and I think the funtion is defined in <conio.h> but I am not sure.