![]() | |
| |||||||
| Home | Register | Projects | Blogs | FAQ | Calendar | Search | Today's Posts | Mark Forums Read | Free Directory | Free DNSReport | Tags |
| Notices |
| Programming Discuss about the various programming languages (HTLM/PHP/ASP/C#/C++/Java etc..) |
C++This is a discussion on "C++" within the Programming part of the Computer Security: Discussions section; 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 ... |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
| 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 |
| Sponsor | ||
| ||
| |
| ||||
| do you mean: int main(int argc,char *argv[]) ? if yes argc here is the number of arguments, program included. and argv[], to select one, as argv[0] is always your program, argv[1] is the switch "-p" in DFind , etc... |
| ||||
| and btw what do you wrote is C , not C++ |
| |||
| Hi there now i use strncat and chain the arguments successively to the buffer. Later in the main function i split them with strtok and assign them to my various pointers. thanx a lot cya hopeless[/b] |
| Sponsor | ||
| ||
| |