C programming IN command line arguments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isaac Help
    New Member
    • Jan 2012
    • 1

    C programming IN command line arguments

    am having problem here with my code Plz Help me Here:

    if((strcmp("-1", argv[1])==0) || (strcmp("-w", argv[1])==0))

    strcpy(&File_na me[0],argv[2]);

    else

    strcpy(&File_na me[0],argv[1]);

    Am getting this:
    warning: incompatible implicit declaration of built-in function 'strcpy'....... ......

    And THis ERROR:
    undefined reference to `WinMain@16|
  • Tassos Souris
    New Member
    • Aug 2008
    • 152

    #2
    have you included string.h ?

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      You need to include braces. Like this:

      Code:
      if((strcmp("-1", argv[1])==0) || (strcmp("-w", argv[1])==0))
      {
       
      strcpy(&File_name[0],argv[2]);
       }
      else
       {
      strcpy(&File_name[0],argv[1]);
       }
      The WinMain error syas you are using Visuak C++ and have created a Windows project but you are not writing a Windows program.

      Do this:
      !) create a Win32 project.
      2) when the wizard appears, do not click finish.
      3) instead, select Applicaton settings
      4) the select empty project and console application.
      5) now click finish.

      Comment

      • Tassos Souris
        New Member
        • Aug 2008
        • 152

        #4
        actuyally if there is only one statement {} are not necessary :)

        Comment

        Working...