Chinaunix首页 | 论坛 | 博客
  • 博客访问: 171430
  • 博文数量: 44
  • 博客积分: 2762
  • 博客等级: 少校
  • 技术积分: 520
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-04 19:19
文章分类
文章存档

2011年(28)

2010年(16)

我的朋友

分类: LINUX

2010-10-07 16:26:04

argc :命令行中参数的个数。
argc :是一个指向字符串的指针数组。

例子:


>chen.c-------------------------------------------------------------------------------------------------------
 1#include <stdio.h>
 2#include<string.h>

 5typedef unsigned char UINT8;
 6typedef UINT8* P_UINT8;
 7
 8const P_UINT8 APL_SET_CHR_TUNING_t[] = {
 9 (P_UINT8)"Digital TV Tuning",
10 (P_UINT8)"",
11 (P_UINT8)"",
12 (P_UINT8)"",
13 (P_UINT8)"\xE6\x95\xB8" "\xE4\xBD\x8D" "\xE9\x9B\xBB" "\xE8\xA6\x96" "\xE8\xAA\xBF" "\xE8\xAB\xA7" "",
14 (P_UINT8)"T832",
15};
16
17
18int main(int argc, char * argv[])
19{
20
21 int i;
22
23 FILE *fpout = fopen(argv[1],"wb");  //借用main的形参传递进来的字符串作为名字
24
25 for(i = 0;i<6;i++)
26 {
27 fwrite((UINT8 *)APL_SET_CHR_TUNING_t[i],strlen(APL_SET_CHR_TUNING_t[i]),1,fpout);
28 fwrite("\0",1,1,fpout);
29 }
30
31 fclose(fpout);
32
33 return 0;
34}

之后运行:
:~test$ gcc chen.c -o test
:~test$ ./test apl_lang.dat

之后可以得到一个apl_lang.dat的文件。


阅读(1060) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~