[問題] 請問簡單的呼叫外部程式
如果我在程式裡需要用到另一個程式的功能
因此需要在兩個程式之間做引數之類的轉換
要怎麼做呢?
ex:
我要呼叫abc.exe這個程式
system("abc.exe");
但是我希望也能傳個字串或數值給abc.exe作運算後
,再傳個字串或數值回來這個程式,請問如何寫呢?
原程式
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(){
system("abc.exe 5");
return 0;
}
程式abc.exe
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int k){
int t;
t=k+1;
printf("%d\n",k);
printf("hello");
return 0;
}
最後printf出來的結果:
3
hello
請問我哪個地方寫錯了呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.4.200
推
06/01 14:36, , 1F
06/01 14:36, 1F
→
06/01 14:37, , 2F
06/01 14:37, 2F
→
06/01 14:39, , 3F
06/01 14:39, 3F
※ 編輯: OoShiunoO 來自: 140.112.4.200 (06/01 14:49)
推
06/01 15:38, , 4F
06/01 15:38, 4F
→
06/01 15:47, , 5F
06/01 15:47, 5F
→
06/01 15:47, , 6F
06/01 15:47, 6F
→
06/01 20:54, , 7F
06/01 20:54, 7F
→
06/01 21:26, , 8F
06/01 21:26, 8F
→
06/01 21:35, , 9F
06/01 21:35, 9F
→
06/01 21:36, , 10F
06/01 21:36, 10F
→
06/01 21:41, , 11F
06/01 21:41, 11F
→
06/01 21:41, , 12F
06/01 21:41, 12F
→
06/02 15:29, , 13F
06/02 15:29, 13F
→
06/02 15:33, , 14F
06/02 15:33, 14F
推
06/02 16:59, , 15F
06/02 16:59, 15F
推
06/02 17:03, , 16F
06/02 17:03, 16F
→
06/02 17:26, , 17F
06/02 17:26, 17F
推
06/02 17:47, , 18F
06/02 17:47, 18F
→
06/02 17:49, , 19F
06/02 17:49, 19F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章