how can i use sscanf to read in input from the command line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Timothy
    New Member
    • Dec 2011
    • 1

    how can i use sscanf to read in input from the command line

    Is there a way I can use sscanf to read in input from the command line??? I would have just used scanf but I want to convert the integers to octal and then logically shift the result. Any reply at all would be appreciated
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You wouldn't use scanf on the command line.

    Learn how to use command line arguments.

    Comment

    • johny10151981
      Top Contributor
      • Jan 2010
      • 1059

      #3
      you would read an integer then convert it to octal(i can assume it would be a character array) and then shift logically,

      does not make sense. help us out, to logically shifting why need to convert it to octal?

      if you want to convert a integer to octal then use sprintf function

      example:
      Code:
      char a[8];//just choosing 8 no reason why 8
      int x=1000;
      sprintf(a,"%o",x); //it would create the octal output and store it in a

      Comment

      • lspxy
        New Member
        • Nov 2011
        • 12

        #4
        fscanf() may do what you want.

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          Each command line argument is a separate string, so you would have to run sscanf on each one.

          Comment

          Working...