I want to use some old C code and firstly I am trying to
compile and run it as a .cpp file. For I/O it uses:
write(1,&c,1); //c is char
write(1,string,count); //where char *string
write(2,"EOF",4);
if((nin=read(0,inbf,INBFSIZ))<=0)
The compiler diagnostics are:
‘write’ undeclared (first use this function)
‘read’ undeclared (first use this function)
No complaints by compiler after some obvious changes.
The old includes are:
include <stdio.h>
include <math.h>
How do I change it simply to do the same thing in today’s C++ ?
I’m using Dev-C++ 4.9.9.2
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I should have been able to find that information
myself somewhere. Yes, I have a book,
perhaps not the right one. When I searched google,
I didn't get the answer. There must be a c++
reference on line somewhere that I could have
searched. Is there one ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Although exist in many Unix & Window C/C++ compilers, neither read() nor write() are C/C++ standar functions.
To this questions I use a help file that comes with the Borland Builder C++ compiler. It has all these functions and a note about the appropriate header and compatibility (Unix, Windows, ANSI C and ANSI C++). Is the "C runtime Library Reference"; the BCB5RTL.HLP file, can be found in the Borland Site (documentation about the Borland C++ compiler).
Old Newbie
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Note that the non-standard functions in the library are properly prefixed with an underscore so read() and write() are deprecated in favour of _read() and _write(). The non-underscored versions are supported for portability.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For a Standar C/C++ reference, esasily available, in Dev-C++ go to:
Tools -> Check for Updates/Packages. There you can download the "C++ reference an Man pages". This package contains a combined chm (help file format) file with cppreference.com and the latest manpages. It include examples, but not the non-standar C/C++ functions.
Old newbie.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to use some old C code and firstly I am trying to
compile and run it as a .cpp file. For I/O it uses:
write(1,&c,1); //c is char
write(1,string,count); //where char *string
write(2,"EOF",4);
if((nin=read(0,inbf,INBFSIZ))<=0)
The compiler diagnostics are:
‘write’ undeclared (first use this function)
‘read’ undeclared (first use this function)
No complaints by compiler after some obvious changes.
The old includes are:
include <stdio.h>
include <math.h>
How do I change it simply to do the same thing in today’s C++ ?
I’m using Dev-C++ 4.9.9.2
Old write() and read() definitions are in <io.h>
That header are in C:\Dev-Cpp\include, so you only need include
include <io.h>
Old newbie.
Exactly what I needed to know, thanks.
I should have been able to find that information
myself somewhere. Yes, I have a book,
perhaps not the right one. When I searched google,
I didn't get the answer. There must be a c++
reference on line somewhere that I could have
searched. Is there one ?
Although exist in many Unix & Window C/C++ compilers, neither read() nor write() are C/C++ standar functions.
To this questions I use a help file that comes with the Borland Builder C++ compiler. It has all these functions and a note about the appropriate header and compatibility (Unix, Windows, ANSI C and ANSI C++). Is the "C runtime Library Reference"; the BCB5RTL.HLP file, can be found in the Borland Site (documentation about the Borland C++ compiler).
Old Newbie
Good tip for an off-line reference, but be cautious - the C Runtime library used by MinGW/GCC is the Microsoft Visual C++ v6 C library documented on-line here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/crthm.asp
Note that the non-standard functions in the library are properly prefixed with an underscore so read() and write() are deprecated in favour of _read() and _write(). The non-underscored versions are supported for portability.
Clifford
For a Standar C/C++ reference, esasily available, in Dev-C++ go to:
Tools -> Check for Updates/Packages. There you can download the "C++ reference an Man pages". This package contains a combined chm (help file format) file with cppreference.com and the latest manpages. It include examples, but not the non-standar C/C++ functions.
Old newbie.