Thread: Contest Sign-Up Thread: Rewrite Mid() from VB

  1. #31
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Re: Re: Contest Sign-Up Thread: Rewrite Mid() from VB

    Originally posted by Sang-drax
    I'd like to judge this contest.
    Finally
    Thank you!

  2. #32
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by Polymorphic OOP
    Do comments count?
    Yes, comment the code!
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #33
    ˇAmo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Sure, I'll help out with the judging.

    Make sure the code is standard. If it doesn't compile on gcc, I'm gonna be ........ed.

  4. #34
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    this looks like an interesting one... i remember i already did this one a while back for an Array class i made, i worked in a different manner though, plus i have no $$$$ing clue how it works... so im not gonna be able to relax till i figure it out now, THANKS! THANKS A WHOOLLLLEEE BUNCH!! here goes hours of my life.

    edit:: this not an entry.
    edit:: its all this one confusing little goddamn line....


    edit:: i figured it out... and its genuis, i might add.

    might i make this post worht something by wishing all the contestants good luck, and the judges too, hehe.
    Last edited by no-one; 03-01-2003 at 06:29 PM.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  5. #35
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by no-one
    this looks like an interesting one... i remember i already did this one a while back for an Array class i made, i worked in a different manner though, plus i have no $$$$ing clue how it works... so im not gonna be able to relax till i figure it out now, THANKS! THANKS A WHOOLLLLEEE BUNCH!! here goes hours of my life.

    edit:: this not an entry.
    edit:: its all this one confusing little goddamn line....


    edit:: i figured it out... and its genuis, i might add.

    might i make this post worht something by wishing all the contestants good luck, and the judges too, hehe.
    Cmon, make it an entry!

  6. #36
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    You can try your functions using this test program.
    It tests various syntactic constructions and the resulting strings.
    Code:
    int main()
    {
        using namespace std;
          
        bool correct = true;
        string s1,s2;  
      
        //Basic test
        s2 = "0123456789";
        string s3 = Mid(s2,1,4);
        s1 = Mid(s2,1,4);
        s2 = Mid("0123456789",1,4);
        if (s1 != "1234" or s2 != "1234" or s3 != "1234")
            cout << "Basic test incorrect : " << s1, correct=false;
        
        
        //First test
        s1 = "abcdefg";
        Mid(s1, 3, 0) = "123";
        if (s1 != "abc123defg")
            cout << "First test incorrect : " << s1, correct=false;
            
            
        //Second test
        s1 = "abcdefg";
        s2 = "123";
        Mid(s1, 3, s2.size()) = s2;
        if (s1 != "abc123g")
            cout << "Second test incorrect : " << s1, correct=false;
    
        //Third test
        s1 = "abc";
        s2 = "123";
        Mid(s1, 1, 1) = Mid(s2,1);
        if (s1 != "a23c")
            cout << "Third test incorrect : " << s1, correct=false;    
        
        if (correct)
            cout << "All tests correct!";
    }
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  7. #37
    nouse
    Guest
    This may provide some ideas:
    Moderator Edit
    See VB string functions.


    Link removed by Hammer - Too close to giving away answers (bad ones at that), imho.

  8. #38
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    Some ideas? This shows up how to do the whole function, maybe with some changes.

    Ahh, and I still think it's possible to do the Mid function with C.

  9. #39
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by Vber
    Some ideas? This shows up how to do the whole function, maybe with some changes.

    Ahh, and I still think it's possible to do the Mid function with C.
    Okay, prove me wrong by doing it. I certainly can't think of any C constuct which would allow you to have a single "function" act in many different ways.

  10. #40
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    on the link the guy posted here, there was the "mid" function writen in pure C.

  11. #41
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Vber
    on the link the guy posted here, there was the "mid" function writen in pure C.
    and it was crap, trust me
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  12. #42
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Vber
    on the link the guy posted here, there was the "mid" function writen in pure C.
    And you could apply "mid(astring,0,2)=mid(astring(2,1);" on it?
    --

  13. #43
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    i'll be entering, I'll have the code in about 20 mins

  14. #44
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Hmmph, 4 hours later and no code?

  15. #45
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Hmm maybe I'm just retarded (in fact I'd bet on it!), but the main thing preventing me from writing this code is this:

    Mid(s1, 3, 0) = "123";

    Apparently my C++ knowledge is too limited, because statements like these don't make much sense to me.

    Mid takes a string, the start location, and the end (or 0 for the whole thing?), and returns these characters as a string. At least, that's what it does in the "Basic test". In the "First test" and after, statements like above are rampant - what does it mean?? From my knowledge, it would mean "make a string from s1 starting at the 3rd char going to the end, and then replace that string with "123"" which obviously isn't what happens.

    So, what am I missing here? Some C++ concept that I haven't learned or have forgotten?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ANN: The Fourth Contest: Alarm Clock, sign up here
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 59
    Last Post: 08-10-2002, 12:24 AM
  2. Sign Up!: The Third Round, both contests
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 54
    Last Post: 07-20-2002, 05:46 PM
  3. Sign Up -- The Next Contest
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 49
    Last Post: 06-26-2002, 06:09 PM
  4. Sign up -- Contest Thread
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 70
    Last Post: 05-27-2002, 06:46 PM
  5. Multi-Thread Programming
    By drdroid in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2002, 02:53 PM