#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#define NEWFILE (O_WRONLY|O_CREAT|O_TRUNC)
#define SIZE 80
int write_buffer(int fd,char *buf,int count);
void case8(int i,char *j);
void default8();
int main(int argc, char * argv[])
{
int outfile,i;
char filename[]={"test.dat"};
char buffer[SIZE];
char *buf;
char *argv2;
printf("%d\n\n\n",argc);
if(argc<=2)
{
default8();
exit(0);
}
switch(atoi(argv[1]))
{
case 0:
{
case8(atoi(argv[1]),argv[2]);
break;
}
case 1:
{
argv2=argv[2];
case8(atoi(argv[1]),argv[2]);
break;
}
case 2:
{
argv2=argv[2];
case8(atoi(argv[1]),argv[2]);
break;
}
case 3:
{
argv2=argv[2];
case8(atoi(argv[1]),argv[2]);
break;
}
default:
{
default8();
}
}
}
/*
for(i=0;i<argc;i++)
{
printf("the argv's value is %d\n",argc);
printf("argv[%d]=%s\n",i,argv[i]);
}
*/
/*
buf = argv[1];
if((outfile=open(filename,NEWFILE,0640))==-1)
{
printf("ERRO,OPEN FILE FAILED!\n");
exit(255);
}
//printf("%s",buf);
fgets(buffer,SIZE-1,stdin);
printf("%s\n",buffer);
if(write_buffer(outfile,buffer,SIZE)==-1)
{
printf("ERROR,WRITE FAILED:\n",strerror(errno));
exit(255);
}
close(outfile);
return 0;
int write_buffer(int fd,char *buf,int count)
{
int n;
n=write(fd,buf,strlen(buf));
return 1;
}
*/
void case8(int i,char *j){
printf("you enter is ./a.o %d %s\n",i,j);
}
void default8(){
printf("which you put a not suitable for our need:");
printf("填加测试企业:../bin/example 0\n");
printf("按照企业id删除企业:../bin/example 1 100071\n");
printf("按照企业名称删除企业:../bin/example 2 \"my enterprise name\"\n");
printf("按照企业名称取得g级邮箱标识:../bin/example 3 \"my enterprise name\"\n");
printf("按照企业id取得g级邮箱标识:../bin/example 4 \"my enterprise ID\"\n");
printf("other:待补充\n");
}
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#define NEWFILE (O_WRONLY|O_CREAT|O_TRUNC)
#define SIZE 80
int write_buffer(int fd,char *buf,int count);
void case8(int i,char *j);
void default8();
int main(int argc, char * argv[])
{
int outfile,i;
char filename[]={"test.dat"};
char buffer[SIZE];
char *buf;
char *argv2;
printf("%d\n\n\n",argc);
if(argc<=2)
{
default8();
exit(0);
}
switch(atoi(argv[1]))
{
case 0:
{
case8(atoi(argv[1]),argv[2]);
break;
}
case 1:
{
argv2=argv[2];
case8(atoi(argv[1]),argv[2]);
break;
}
case 2:
{
argv2=argv[2];
case8(atoi(argv[1]),argv[2]);
break;
}
case 3:
{
argv2=argv[2];
case8(atoi(argv[1]),argv[2]);
break;
}
default:
{
default8();
}
}
}
/*
for(i=0;i<argc;i++)
{
printf("the argv's value is %d\n",argc);
printf("argv[%d]=%s\n",i,argv[i]);
}
*/
/*
buf = argv[1];
if((outfile=open(filename,NEWFILE,0640))==-1)
{
printf("ERRO,OPEN FILE FAILED!\n");
exit(255);
}
//printf("%s",buf);
fgets(buffer,SIZE-1,stdin);
printf("%s\n",buffer);
if(write_buffer(outfile,buffer,SIZE)==-1)
{
printf("ERROR,WRITE FAILED:\n",strerror(errno));
exit(255);
}
close(outfile);
return 0;
int write_buffer(int fd,char *buf,int count)
{
int n;
n=write(fd,buf,strlen(buf));
return 1;
}
*/
void case8(int i,char *j){
printf("you enter is ./a.o %d %s\n",i,j);
}
void default8(){
printf("which you put a not suitable for our need:");
printf("填加测试企业:../bin/example 0\n");
printf("按照企业id删除企业:../bin/example 1 100071\n");
printf("按照企业名称删除企业:../bin/example 2 \"my enterprise name\"\n");
printf("按照企业名称取得g级邮箱标识:../bin/example 3 \"my enterprise name\"\n");
printf("按照企业id取得g级邮箱标识:../bin/example 4 \"my enterprise ID\"\n");
printf("other:待补充\n");
}
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/768/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2009-11-20 10:58
评论列表