Sunday, 29 October 2017

Command Line Argument in CodeBlocks

How to run a program in CodeBlocks explained with the example


Step1: Type the program in CodeBlocks and save with the name “even.c”


int main(int argc, char *argv[])
            printf("\nArgument not in correct format\n");


        printf("\nEVEN NUMBER\n");
        printf("\nODD NUMBER\n");

return 0;


Step 2: Compile the program by clicking on Build

Step 3: Open Command Prompt 

Now you need to open the Directory where you have saved your program 
( Shown in image STEP 1 )

To run just type program name 
( Shown in image STEP 2 )

 To pass Arguments in the program type :      <program_name> <space> <argument>
  Ex:     even 4 ↵ 

Output will be Displayed .

No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...