史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 軟體應用問題討論區
忘記密碼?
論壇說明

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


發文 回覆
 
主題工具 顯示模式
舊 2003-04-09, 10:57 PM   #1
alex001
榮譽勳章

勳章總數
UID -
在線等級:
文章: n/a
精華:
Question C語言中字串的合併 (左右加入")

各位大家好!
在C語言中有一個傳入參數的寫法,因為我想在傳入的值,加上左" 及右"
我的C語言還不夠好,所以總是有錯誤,能請各位指點一下嗎?謝謝..
下面是我的程式,請各位看一下.(註解的地方是我想加入,但有問題的地方)
比方Compiler後檔名為test.exe,在Dos下執行
C:>test 0001
會輸出成 C:>BARCODE 40,150,\"39\",40,0,0,2,4,"0001

#define string1 "DIRECTION 1"
#define string2 "DENSITY 12"
#define string3 "SPEED 3.0"
#define string4 "REFERENCE 0,0"
#define string5 "SIZE 32 mm,25 mm"
#define string6 "GAP 3 mm,0"
#define string7 "CLS"
#define string8 "TEXT 30,10,\"5\",0,1,1,\"5678\""
#define string9 "TEXT 30,80,\"5\",0,1,1,\"1234\""

#define string11 "PRint 1,1"
#include<stdio.h>
#include<ctype.h>
#include<string.h>
main(int argc, char *argv[])
{
char s1[]="BARCODE 40,150,\"39\",40,0,0,2,4,";
/*char s2="/x22";*/
/*strncat(s2,argv[1],20);*/
char string10[80];
void concat();
concat(s1,argv[1],string10);
if(argc != 2)
{
printf("Incorrect Format!!\n");
printf("print try again!!\n");
exit(1);
}
{
fprintf(stdprn,"%s \n",string1);
fprintf(stdprn,"%s \n",string2);
fprintf(stdprn,"%s \n",string3);
fprintf(stdprn,"%s \n",string4);
fprintf(stdprn,"%s \n",string5);
fprintf(stdprn,"%s \n",string6);
fprintf(stdprn,"%s \n",string7);
fprintf(stdprn,"%s \n",string8);
fprintf(stdprn,"%s \n",string9);
fprintf(stdprn,"%s \n",string10);
fprintf(stdprn,"%s ",string11);
}
}
void concat(char str1[],char str2[],char str3[])
{
int i,j,k;
for(i=0;str1[i]!=\0;i++)
str3[i]=str1[i];
for(j=0;str2[j]!=\0;j++)
str3[i+j]=str2[j];
str3[i+j]=\0;
}
 
送花文章: 0, 收花文章: 0 篇, 收花: 0 次
回覆時引用此帖
發文 回覆



發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用


所有時間均為台北時間。現在的時間是 05:50 AM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1