Click here to Skip to main content
15,887,485 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DDX_CONTROL vs Create for Cricheditctrl and effects on Streaming Pin
Code-o-mat14-Oct-09 8:08
Code-o-mat14-Oct-09 8:08 
GeneralRe: DDX_CONTROL vs Create for Cricheditctrl and effects on Streaming Pin
ForNow14-Oct-09 12:21
ForNow14-Oct-09 12:21 
QuestionGet OS information Pin
includeh1013-Oct-09 10:52
includeh1013-Oct-09 10:52 
AnswerRe: Get OS information Pin
«_Superman_»13-Oct-09 11:18
professional«_Superman_»13-Oct-09 11:18 
QuestionBinary Tree traversal Pin
mood4813-Oct-09 6:39
mood4813-Oct-09 6:39 
AnswerRe: Binary Tree traversal Pin
David Crow13-Oct-09 7:03
David Crow13-Oct-09 7:03 
AnswerRe: Binary Tree traversal Pin
Alan Balkany15-Oct-09 4:40
Alan Balkany15-Oct-09 4:40 
QuestionI have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 5:50
Mohamed_Khalil13-Oct-09 5:50 
Hi guys ,

I've problem with C in Linux, and just i need to pass args to execvp(args[0],args) to the main function and after creating child process and the code is :
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#define MAX_LINE 80

void setup(char inputBuffer[],char *args[],int *background)
{
int i;
int cmd=0;
int l;

  
scanf("%s",inputBuffer);//input command

if("%d",strlen(inputBuffer)>80)  //check the command; if the command >80 will give an error and exit the process,otherwise it will complete the process
{
 printf("error the maximum size is 80\n"); 
exit(-1);
}

else
{
  args  = &inputBuffer;
   
  }
    

}


int main(void)
{

char inputBuffer[MAX_LINE];
int  background =0;
char *args[MAX_LINE/2+1];
char *command;


while(1)
{
background=0;
printf("Command ->");
setup(inputBuffer,args,&background);

pid_t pChild;
pChild = fork();


if(pChild <0){
printf("Error\n");
exit(-1);
}

if(pChild==0)
{ 
execvp(args[0],args);
}


else {
if(background=1);

wait(NULL);

printf("Child process completed\n");
}
exit(0);
}
}

QuestionRe: I have problem with C for passing ARGS to main function in LINUX Pin
David Crow13-Oct-09 6:20
David Crow13-Oct-09 6:20 
AnswerRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 6:25
Mohamed_Khalil13-Oct-09 6:25 
AnswerRe: I have problem with C for passing ARGS to main function in LINUX Pin
David Crow13-Oct-09 6:28
David Crow13-Oct-09 6:28 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 6:33
Mohamed_Khalil13-Oct-09 6:33 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 6:39
Mohamed_Khalil13-Oct-09 6:39 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
David Crow13-Oct-09 6:43
David Crow13-Oct-09 6:43 
AnswerRe: I have problem with C for passing ARGS to main function in LINUX Pin
Richard MacCutchan13-Oct-09 6:39
mveRichard MacCutchan13-Oct-09 6:39 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 6:53
Mohamed_Khalil13-Oct-09 6:53 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Richard MacCutchan13-Oct-09 7:04
mveRichard MacCutchan13-Oct-09 7:04 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 7:10
Mohamed_Khalil13-Oct-09 7:10 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Richard MacCutchan13-Oct-09 7:20
mveRichard MacCutchan13-Oct-09 7:20 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 7:25
Mohamed_Khalil13-Oct-09 7:25 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Mohamed_Khalil13-Oct-09 7:29
Mohamed_Khalil13-Oct-09 7:29 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Richard MacCutchan13-Oct-09 9:12
mveRichard MacCutchan13-Oct-09 9:12 
GeneralRe: I have problem with C for passing ARGS to main function in LINUX Pin
Bram van Kampen13-Oct-09 12:58
Bram van Kampen13-Oct-09 12:58 
QuestionLOGINREC problem...IN VISTA machine under VS-2008 Pin
Vetukuri Raju13-Oct-09 5:48
Vetukuri Raju13-Oct-09 5:48 
AnswerRe: LOGINREC problem...IN VISTA machine under VS-2008 Pin
«_Superman_»13-Oct-09 9:10
professional«_Superman_»13-Oct-09 9:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.