Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. sscanf: parsing a file

sscanf: parsing a file

Scheduled Pinned Locked Moved C / C++ / MFC
questionregexjson
40 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T tom groezer

    LunaticFringe wrote: Take it as a compliment. Good point. --->which one. you being a ganja LunaticFringe wrote: Hell, your English is probably better than mine. pallini Nah, my English is actually bad. Anyway now it is a bit better, thanks to all the people mocking me when I started to post in the Lounge, few years ago. Hope your attitute also shines like you head when people mock you in days to come :) Big Grin

    CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #27

    I hope your brilliant brain will eventually overcome the 'skip blanks and tabs' daunting trouble. :laugh:

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    In testa che avete, signor di Ceprano?

    C T J 3 Replies Last reply
    0
    • CPalliniC CPallini

      I hope your brilliant brain will eventually overcome the 'skip blanks and tabs' daunting trouble. :laugh:

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      C Offline
      C Offline
      Covean
      wrote on last edited by
      #28

      Thanks (oh my master ;P ) this saved my day! :laugh:

      Greetings Covean

      1 Reply Last reply
      0
      • CPalliniC CPallini

        I hope your brilliant brain will eventually overcome the 'skip blanks and tabs' daunting trouble. :laugh:

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        T Offline
        T Offline
        tom groezer
        wrote on last edited by
        #29

        thanks my optimistic philospher. you work full time on this board and are getting paid for the shit u speak.

        J 1 Reply Last reply
        0
        • CPalliniC CPallini

          I hope your brilliant brain will eventually overcome the 'skip blanks and tabs' daunting trouble. :laugh:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          J Offline
          J Offline
          jeron1
          wrote on last edited by
          #30

          5! :thumbsup:

          1 Reply Last reply
          0
          • T tom groezer

            thanks my optimistic philospher. you work full time on this board and are getting paid for the shit u speak.

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #31

            If you spent half the time working on your problem than you do hurling insults, you probably would answered your own question hours ago.

            1 Reply Last reply
            0
            • T tom groezer

              Hi, I need to parse a file which has spaces and tabs with some entries that i need to pull. I'm using sscanf function. How do I ensure that I skip the spaces and tabs which could be in randon number. What could be a regular expression for this?

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #32

              I'm not quite sure what you've done to annoy CPallini... but he has my trust, so I assume you deserve the long flamewar above this post. But *I'm* in a good mood... I would not use the sscanf function at all for this. One, the tabs / spaces are delimiters. In which case, read a line of text in, then use your favourite string classes Find function to get the next whitespace. Then parse the next up to that point. Delete the text you've parsed, and repeat. OK, once you've broken the long line into stringlets, then you can use sscanf if you like! Good luck, Iain.

              I have now moved to Sweden for love (awwww).

              CPalliniC 1 Reply Last reply
              0
              • T tom groezer

                Hi, I need to parse a file which has spaces and tabs with some entries that i need to pull. I'm using sscanf function. How do I ensure that I skip the spaces and tabs which could be in randon number. What could be a regular expression for this?

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #33

                After your tirade to other professionals here, you surely do not deserve any help.

                tom groezer wrote:

                I need to parse a file... I'm using sscanf function.

                Which means you are using the wrong tool for the job. fscanf() would be used to parse the file, while sscanf() would be used to parse a string read from the file. There is a subtle but big difference. Learn that difference and you'll save yourself many bouts with foot-in-mouth disease.

                tom groezer wrote:

                How do I ensure that I skip the spaces and tabs which could be in randon number.

                Is it really that hard to find something like:

                char *str = "I really\tdo \t not deserve any\t help";
                char s1[8], s2[8], s3[8], s4[8], s5[8], s6[8], s7[8];
                sscanf(str, "%s %s %s %s %s %s %s", s1, s2, s3, s4, s5, s6, s7);

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Man who follows car will be exhausted." - Confucius

                1 Reply Last reply
                0
                • CPalliniC CPallini

                  tom groezer wrote:

                  a******le. Parese the space in between

                  I'm not able to skip the blanks and the tabs, please provide me code... :-\

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  T Offline
                  T Offline
                  Tim Craig
                  wrote on last edited by
                  #34

                  Zing! :thumbsup:

                  You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                  1 Reply Last reply
                  0
                  • T tom groezer

                    I need to to talk to all slaves of that lang :))

                    T Offline
                    T Offline
                    Tim Craig
                    wrote on last edited by
                    #35

                    If it wasn't for English, you Indians mostly couldn't talk to each other. :doh:

                    You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                    1 Reply Last reply
                    0
                    • T tom groezer

                      I guess you are not a software developer but rather a philoshpher who thinks about those sentences. I need a urgent fix and dont want to travel googling. I guess the forum is to get answer and not to fight around and highjacking

                      T Offline
                      T Offline
                      Tim Craig
                      wrote on last edited by
                      #36

                      tom groezer wrote:

                      I need a urgent fix and dont want to travel googling.

                      It doesn't get much faster than Googling so get used to it. If you had a clue, you'd have had your answer before you could post here.

                      You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                      1 Reply Last reply
                      0
                      • I Iain Clarke Warrior Programmer

                        I'm not quite sure what you've done to annoy CPallini... but he has my trust, so I assume you deserve the long flamewar above this post. But *I'm* in a good mood... I would not use the sscanf function at all for this. One, the tabs / spaces are delimiters. In which case, read a line of text in, then use your favourite string classes Find function to get the next whitespace. Then parse the next up to that point. Delete the text you've parsed, and repeat. OK, once you've broken the long line into stringlets, then you can use sscanf if you like! Good luck, Iain.

                        I have now moved to Sweden for love (awwww).

                        CPalliniC Offline
                        CPalliniC Offline
                        CPallini
                        wrote on last edited by
                        #37

                        I love you, man (expecially with the warrior outfit). :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                        [My articles]

                        In testa che avete, signor di Ceprano?

                        T 1 Reply Last reply
                        0
                        • CPalliniC CPallini

                          I love you, man (expecially with the warrior outfit). :)

                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                          [My articles]

                          T Offline
                          T Offline
                          Tim Craig
                          wrote on last edited by
                          #38

                          CPallini wrote:

                          expecially with the warrior outfit

                          Since he moved to Sweden, does that involve a big helmet with horns? :laugh: And yes, I know the Vikings didn't actually wear those but they're cool anyhow. :cool:

                          You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                          CPalliniC 1 Reply Last reply
                          0
                          • T Tim Craig

                            CPallini wrote:

                            expecially with the warrior outfit

                            Since he moved to Sweden, does that involve a big helmet with horns? :laugh: And yes, I know the Vikings didn't actually wear those but they're cool anyhow. :cool:

                            You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                            CPalliniC Offline
                            CPalliniC Offline
                            CPallini
                            wrote on last edited by
                            #39

                            I think you missed something [^]... :-D

                            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                            [My articles]

                            In testa che avete, signor di Ceprano?

                            T 1 Reply Last reply
                            0
                            • CPalliniC CPallini

                              I think you missed something [^]... :-D

                              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                              [My articles]

                              T Offline
                              T Offline
                              Tim Craig
                              wrote on last edited by
                              #40

                              Guess so! :doh: I don't usually check the profiles of people I'm familiar with. Guess we'd better send the word out that a raiding party is on the way. :laugh:

                              You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups