Steve
05-07-05, 20:22
hi there
i have the following problem
i want to read multiple args through scanf and but them
out in main. my prob is that i want to use different args :-)
something like the main(char *args[]) function
where i can also pass different args through the command line
9 ################################
10 Ausgabe
11 Arg1: test
12 Arg2: test
13
14 #include "stdafx.h"
15 #include "stdio.h"
16 #include "string.h"
17
18 char buffer[100];
19
20 void insertarg(char *argv[]){
21
22 scanf("%s",buffer);
23 argv[0]=buffer;
24 scanf("%s",buffer);
25 argv[1]=buffer;
26 }
27
28 int main(){
29 char *my_argv[2];
30 insertarg(my_argv);
31 printf("Arg 1: %s\n",my_argv[0]);
32 printf("Arg 2: %s\n",my_argv[1]);
33 }
34
35 thanx a lot
36 hopeless
37
i have the following problem
i want to read multiple args through scanf and but them
out in main. my prob is that i want to use different args :-)
something like the main(char *args[]) function
where i can also pass different args through the command line
9 ################################
10 Ausgabe
11 Arg1: test
12 Arg2: test
13
14 #include "stdafx.h"
15 #include "stdio.h"
16 #include "string.h"
17
18 char buffer[100];
19
20 void insertarg(char *argv[]){
21
22 scanf("%s",buffer);
23 argv[0]=buffer;
24 scanf("%s",buffer);
25 argv[1]=buffer;
26 }
27
28 int main(){
29 char *my_argv[2];
30 insertarg(my_argv);
31 printf("Arg 1: %s\n",my_argv[0]);
32 printf("Arg 2: %s\n",my_argv[1]);
33 }
34
35 thanx a lot
36 hopeless
37