问题,为什么C里能用,C++用不了。
#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include <dir.h>
#include <stdlib.h>
void main(int argc, char *argv[])
{
char str[256],bm[4],*ml,*kb,wjm[256],de[256];
int i,z,js,js1,js2,js3,js4;
js3=0;
*kb = 0x00;//用指针时必须先指定起始地址,
*ml = 0x00;//否则会出错。
//*wjm = 0x00;
de[0]='d';
de[1]='e';
de[2]='l';
de[3]=' ';
js4=4;
while(argv[1][js3])
{ wjm[js3]=argv[1][js3];
de[js4]=argv[1][js3];
js3+=1;
js4+=1;
}
de[js4]='\0';
// cout<<de;
wjm[js3]='.';
wjm[js3+1]='t';
wjm[js3+2]='x';
wjm[js3+3]='t';
wjm[js3+4]='\0';
kb[0]='c';
kb[1]='o';
kb[2]='p';
kb[3]='y';
kb[4]=' ';
ml[0]='d';
ml[1]='i';
ml[2]='r';
ml[3]=' ';
if ( argc==1)
{
cout<<"error";
//return;
exit(0);
}
FILE *fl, *ft;
int ch;
fl = fopen(argv[1] , "rb" );
ft = fopen( "temp", "wb" );
while (!feof(fl) ) {
ch = getc( fl );
// if ( feof( fl ) ) break;
if ( ch==0x8d ) {
ch = 0x0d; }
fputc( ch, ft );
}
fclose(fl);
fclose(ft);
// char ch[256],str[256],bm[4];
// int i,z;
// if (argc>1 && argc==0)
// cout<<"error";
ifstream wj;
wj.open("temp");
ofstream temp;
// temp.open(argv[1]);
temp.open(wjm);
// cout<<"请输入二位编码";
// cin>>bm;
//temp.open("temp.txt");
wj.getline(str,256);
// cout<<str;
while (wj)
{
if ((str[0]>'A' && str[0]<'Z') && strlen(str)<11)//&&(str[9]='' and and str[9]=\0)
{
temp<<"{cl}"<<str<<endl;
wj.getline(str,256);
}
// wj.getline(str,256);
if(str[0]=='[' && str[1]=='Z' && str[4]==']')
{
temp<<str<<endl;
// temp<<bm<<endl;
temp<<'['<<argv[1][4]<<argv[1][5]<<']'<<endl;
wj.getline(str,256);
temp<<"{so}"<<str<<endl;
wj.getline(str,256);
temp<<"{au}"<<str<<endl;
wj.getline(str,256);
}
else
{
temp<<str<<endl;
wj.getline(str,256);
}
}
wj.close();
temp.close();
system("del temp");
js=0;
js1=5;
js2=4;
while(wjm[js])
{ kb[js1]=wjm[js];
ml[js2]=wjm[js];
// de[js2]=wjm[js];
js2++;
js1++;
js++;
}
kb[js1]=' ';
kb[js1+1]='h';
kb[js1+2]=':';
kb[js1+3]='\0';
ml[js2]='\0';
// cout<<ml;
system(ml);
cout<<kb;
system(kb);
cout<<de;
system(de);
}
上面有一段把软回车,变成硬回车, 可是在C++里软回车的值不认, 可是C就认,这是为什么呀。
还有我想用指针实现动态数组,是必须先把指针给个值吗?(开始没给值,死机)
我想实现DOS里的命令, 可是SYSTEM只能放字符串,有没有其它的办法。