新手求教,c++调用类是不是只要#include(类名)就可以了,小弟我这样调用提示说打不开那个类(是另外下载的)
新手求教,c++调用类是不是只要#include(类名)就可以了,我这样调用提示说打不开那个类(是另外下载的)
还有在编译的时候提示这样的信息。应该怎么修改:
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(15) : error C2065: 'outportb ' : undeclared identifier
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(27) : error C2065: 'inportb ' : undeclared identifier
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(114) : error C2065: 'sendch ' : undeclared identifier
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(115) : error C2065: 'recievefile ' : undeclared identifier
下面是源程序
#include <sys\stat.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <CONIO.H>
#define COM1 0x2f8
#define COM2 0x2f8
void SendCh() {
unsigned char status;
int i,c;
int flag=1;
outportb(COM1+1,0x00);
outportb(COM1+1,0x40);
outportb(COM1+1,0xcf);
outportb(COM1+1,0x37);
printf( "Input a character: ");
while(flag) {
c=getch();
putchar(c);
if (c==27) flag=0;
for (i=0;i <=1000;i++);
do {
status=inportb(0x2f9);
status=status & 0x01;
}while (status==0);
outportb(COM1,c);
}
printf( "complete\n ");
}
void goon()
{
printf( "Press any key to continue...\n ");
while (!kbhit()) ;
getch();
}
void ReceiveCh() {
int i;
char ch=0;
unsigned char status;
outportb(COM2+1,0xAA);
outportb(COM2+1,0x50);
outportb(COM2+1,0xcf);
outportb(COM2+1,0x14);
printf( "Receiving ...\n ");
while(ch!=27) {
for (i=0;i <=1000;i++);
do {
status=inportb(COM2+5);
status=status & 0x01;
}while (status==0);
ch=inportb(COM2);
printf( "%c ",ch);
}
}
void Receivefile() {
FILE *fp;
int handle;
int flag=1;
char c;
int i;
unsigned char status;
char fname[]= "receive.txt ";
outportb(COM2+1,0xAA);
outportb(COM2+1,0x50);
outportb(COM2+1,0xcf);
outportb(COM2+1,0x14);
handle=creat(fname, S_IREAD|S_IWRITE);
if(handle==-1) {
printf( "Creat file Faild.\n ");
exit(0);
}
if((fp=fopen(fname, "w "))==NULL) {
printf( "Open file Faild.\n ");
exit(0);
}
printf( "Receiving file(rename:receive.txt)...\n\n ");
while(flag) {
do {
status=inportb(COM2+5);
status=status & 0x01;
}while (status==0);
c=inportb(COM2);
for (i=0;i <=1000;i++);
if(c==27) {
fclose(fp);
flag=0;
printf( "%c ",c);
break;
}
printf( "%c ",c);
fputc(c,fp);
}
close(handle);
printf( "\n\n ok \n ");
}
void main(){
char ch=0;
还有在编译的时候提示这样的信息。应该怎么修改:
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(15) : error C2065: 'outportb ' : undeclared identifier
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(27) : error C2065: 'inportb ' : undeclared identifier
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(114) : error C2065: 'sendch ' : undeclared identifier
D:\tools\Microsoft Visual Studio\MyProjects\tongxun\tongxun.cpp(115) : error C2065: 'recievefile ' : undeclared identifier
下面是源程序
#include <sys\stat.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <CONIO.H>
#define COM1 0x2f8
#define COM2 0x2f8
void SendCh() {
unsigned char status;
int i,c;
int flag=1;
outportb(COM1+1,0x00);
outportb(COM1+1,0x40);
outportb(COM1+1,0xcf);
outportb(COM1+1,0x37);
printf( "Input a character: ");
while(flag) {
c=getch();
putchar(c);
if (c==27) flag=0;
for (i=0;i <=1000;i++);
do {
status=inportb(0x2f9);
status=status & 0x01;
}while (status==0);
outportb(COM1,c);
}
printf( "complete\n ");
}
void goon()
{
printf( "Press any key to continue...\n ");
while (!kbhit()) ;
getch();
}
void ReceiveCh() {
int i;
char ch=0;
unsigned char status;
outportb(COM2+1,0xAA);
outportb(COM2+1,0x50);
outportb(COM2+1,0xcf);
outportb(COM2+1,0x14);
printf( "Receiving ...\n ");
while(ch!=27) {
for (i=0;i <=1000;i++);
do {
status=inportb(COM2+5);
status=status & 0x01;
}while (status==0);
ch=inportb(COM2);
printf( "%c ",ch);
}
}
void Receivefile() {
FILE *fp;
int handle;
int flag=1;
char c;
int i;
unsigned char status;
char fname[]= "receive.txt ";
outportb(COM2+1,0xAA);
outportb(COM2+1,0x50);
outportb(COM2+1,0xcf);
outportb(COM2+1,0x14);
handle=creat(fname, S_IREAD|S_IWRITE);
if(handle==-1) {
printf( "Creat file Faild.\n ");
exit(0);
}
if((fp=fopen(fname, "w "))==NULL) {
printf( "Open file Faild.\n ");
exit(0);
}
printf( "Receiving file(rename:receive.txt)...\n\n ");
while(flag) {
do {
status=inportb(COM2+5);
status=status & 0x01;
}while (status==0);
c=inportb(COM2);
for (i=0;i <=1000;i++);
if(c==27) {
fclose(fp);
flag=0;
printf( "%c ",c);
break;
}
printf( "%c ",c);
fputc(c,fp);
}
close(handle);
printf( "\n\n ok \n ");
}
void main(){
char ch=0;