//The below mentioned code is not working on my C compiler.The //errors im getting is :(1)Extra parameter in call to_ inport b_.
//(2)Too few parameters in call to "outport".(line 25)
//(3)Not an allowed type(line 25)


void main()
    char data;
    int choice;

  printf("Enter the choice to send or receive from COM1::");

      printf("Enter data to send::");

printf("reding from  COM1::%d",data);


Recommended Answers

All 8 Replies

you can not use inport and outpout with any 32-bit or 64-bit compiler. Those functions are no longer supported by the operating system. On MS-Windows you will have to use win32 api functions, starting with OpenFile() to open the com port, ReadFile() to read from it, and WriteFile() to write to it. Here is a complete list of communications functions.

i have done serial and parallel port interfacing in past and i can understand at the start it looks very hard. However your approach to the problem is right and the compiler which might do the task for you is Turbo C. It is a really old compiler and does not even allow you to use mouse , but it works very well for serial and parallel ports.

Thanks for your answer.But Im using TurboC++ IDE and can somebody suggest me a solution for the above mentioned error.I changed the code with openFile and closeFile.Still that error is coming..Also what is this 0x03f8 referring to...Is that a particular COM1 port address ?.Is this COM port address change from computer to computer?Any tutorials regarding to this?

Yes, the 0x03f8 is the com port address for MS-DOS 6.X operating system. If you read through the links I posted you will find examples how to open the com port.

Are you using the 16-bit version of TurboC++ or the newer 32-bit version ? You can not use win32 api functions from the old 16-bit version of that compiler. My recommendation is to ditch that compiler and get a new one, such as Code::Blocks or VC++ 2008 Express, both are free.

I am using Borland Turbo C++ version 3.0
Copyright 1990-92 and to be frank I don't know whether it is 16 bit or 32 bit.

Does it use memory models, such as small, medium, compact and large? If yes, then it is a 16-bit compiler.

Yes ,in the help search I found "m Compiler Option" and in that

mc-Compact memory model
mh-huge memory model
ml-large memory model
mm-medium memory model and several other options are available.
So it is a 16bit compiler.
Thanks a lot...

In that case go back to the code you originally posted here. inportb() only takes one parameter. It returns the byte read.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.