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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. string help whats wrong with this code?

string help whats wrong with this code?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
17 Posts 2 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.
  • S Steven Richardson 0

    soory i just got it thatnks a lot!!!!!!!!

    N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #6

    The input string was :- abc{ghj{popeye}jjj The output string is :- popeye That's what you wanted huh? Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

    S 1 Reply Last reply
    0
    • N Nish Nishant

      The input string was :- abc{ghj{popeye}jjj The output string is :- popeye That's what you wanted huh? Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

      S Offline
      S Offline
      Steven Richardson 0
      wrote on last edited by
      #7

      thanks i just got it!:)

      S 1 Reply Last reply
      0
      • S Steven Richardson 0

        thanks i just got it!:)

        S Offline
        S Offline
        Steven Richardson 0
        wrote on last edited by
        #8

        i have just got an error wit the line: y=strchr(t,'}'); on running it i changed the code a bit to: char abc[1000]; char *Input; strcpy(abc,Input); char *t,*y; t=strrchr(abc,'{'); y=strchr(t,'}'); if(y) *y=0; cout << t+1; HidPass = t; does this have anything to do with it?

        N 1 Reply Last reply
        0
        • S Steven Richardson 0

          i have just got an error wit the line: y=strchr(t,'}'); on running it i changed the code a bit to: char abc[1000]; char *Input; strcpy(abc,Input); char *t,*y; t=strrchr(abc,'{'); y=strchr(t,'}'); if(y) *y=0; cout << t+1; HidPass = t; does this have anything to do with it?

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #9

          You need to do one more pointer validity check.

          char abc[1000];
          char *Input; //better alloc some memory here
          strcpy(abc,Input);
          char *t,*y;
          t=strrchr(abc,'{');
          if (t) y=strchr(t,'}');
          if(y) *y=0;
          if(t) cout << t+1;
          HidPass = t+1;//remember the plus one here

          Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

          S 1 Reply Last reply
          0
          • N Nish Nishant

            You need to do one more pointer validity check.

            char abc[1000];
            char *Input; //better alloc some memory here
            strcpy(abc,Input);
            char *t,*y;
            t=strrchr(abc,'{');
            if (t) y=strchr(t,'}');
            if(y) *y=0;
            if(t) cout << t+1;
            HidPass = t+1;//remember the plus one here

            Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

            S Offline
            S Offline
            Steven Richardson 0
            wrote on last edited by
            #10

            sorry about all this but now it has a problem with HidPass = t+1;//remember the plus one here:(( :((

            N 1 Reply Last reply
            0
            • S Steven Richardson 0

              sorry about all this but now it has a problem with HidPass = t+1;//remember the plus one here:(( :((

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #11

              Is HidPass declared as a char* and if so, has it been allocated some memory using new or malloc? By the way if the answer is "yes" to the above question replace that line with :- if(t) HidPass=t+1; Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

              S 1 Reply Last reply
              0
              • N Nish Nishant

                Is HidPass declared as a char* and if so, has it been allocated some memory using new or malloc? By the way if the answer is "yes" to the above question replace that line with :- if(t) HidPass=t+1; Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

                S Offline
                S Offline
                Steven Richardson 0
                wrote on last edited by
                #12

                i dont get any errors now it just does not work? HidPass does not equal anything?

                S 1 Reply Last reply
                0
                • S Steven Richardson 0

                  i dont get any errors now it just does not work? HidPass does not equal anything?

                  S Offline
                  S Offline
                  Steven Richardson 0
                  wrote on last edited by
                  #13

                  hang on i know why thanks for your help

                  N 1 Reply Last reply
                  0
                  • S Steven Richardson 0

                    hang on i know why thanks for your help

                    N Offline
                    N Offline
                    Nish Nishant
                    wrote on last edited by
                    #14

                    Steven Richardson wrote: hang on Okay :-) Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

                    S 1 Reply Last reply
                    0
                    • N Nish Nishant

                      Steven Richardson wrote: hang on Okay :-) Nish Nish was here, now Nish has gone; He left his soul, to turn you on; Those who knew Nish, knew him well; Those who didn't, can go to hell. I like to :jig: on the Code Project Sonork ID 100.9786 voidmain www.busterboy.org

                      S Offline
                      S Offline
                      Steven Richardson 0
                      wrote on last edited by
                      #15

                      you said char *Input; //better alloc some memory here how do i do that? and i know why it is not working! cos as soon as Input becomes a char it screws up and does not equal what it should?

                      N 1 Reply Last reply
                      0
                      • S Steven Richardson 0

                        you said char *Input; //better alloc some memory here how do i do that? and i know why it is not working! cos as soon as Input becomes a char it screws up and does not equal what it should?

                        N Offline
                        N Offline
                        Nish Nishant
                        wrote on last edited by
                        #16

                        Steven Richardson wrote: you said char *Input; //better alloc some memory here how do i do that? char *Input = new char[1024]; or char Input[1024]; Nish CPUA # 0x0666 Sonork ID 100.9786 voidmain www.busterboy.org

                        S 1 Reply Last reply
                        0
                        • N Nish Nishant

                          Steven Richardson wrote: you said char *Input; //better alloc some memory here how do i do that? char *Input = new char[1024]; or char Input[1024]; Nish CPUA # 0x0666 Sonork ID 100.9786 voidmain www.busterboy.org

                          S Offline
                          S Offline
                          Steven Richardson 0
                          wrote on last edited by
                          #17

                          Input cannot be made in to a char as it no longer equals what it should so as a AnsiString it equals: save that{ste} and as a char it equals:ÈóI

                          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