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

  1. #46
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I'm in.

    gg

  2. #47
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Added
    Need one more judge.
    Code:
    Mid(s1, 3, 0) = "123";
    Does this make sense: "Replace 0 characters in s1 at position 3 with '123'"

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

  3. #48
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    here's one possibility with regards to 0 length Mid()'s;
    Code:
    string s1 = "abcdefg";
    cout << (Mid(s1,3,0) = "123") << endl;
    Output:
    abc123defg

    gg

  4. #49
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905

    eibro

    lmao, y'know, i posted that earlier, and I got side-tracked on one of my new games....lmao....i guess i probably won't even enter sorry bout that

    ...........thanks for noticing eibro.....lol

  5. #50
    Contest_Master
    Guest
    Recieved Entries from:
    Travis Dane
    Codeplug
    Sebastiani
    Sang-Drax [although he's judging]
    Deadline is midnight tommorow.

  6. #51
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Contest is over in this timezone! I'll accept any entries I get before I check tommorow.
    I've recieved entired from "[email protected]" and "Dorian Boyce", either of you want to enlighten me to your screen name?

  7. #52
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    What should this code do?

    Mid("12345",1,1) = "aaa";

    Undefined?
    An exception?
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  8. #53
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    I guess the best option would be if it didn't compile at all:
    Code:
    const std::string s1 = "abc";
    Mid(s1,0) = "123"; //SHOULDN'T COMPILE
    Mid("abc",0) = "123" //SHOULDN'T COMPILE
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  9. #54
    Registered User
    Join Date
    Jan 2002
    Posts
    552
    Dorian Boyce is me
    C Code. C Code Run. Run Code Run... Please!

    "Love is like a blackhole, you fall into it... then you get ripped apart"

  10. #55
    Registered User
    Join Date
    Mar 2003
    Posts
    143
    ... and [email protected] is me ...

    DavT

  11. #56
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    What's the status here? We still working on some results??

    gg

  12. #57
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    Code:
    const std::string s1 = "abc";
    Mid(s1,0) = "123"; //SHOULDN'T COMPILE
    Mid("abc",0) = "123" //SHOULDN'T COMPILE
    um yes they should, your forgeting that the assignment works on the returned value or object so, what appears to be an assignment to the function is actually assignement to the functions return.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  13. #58
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I agree with you in that it should compile (cuz my version of it does ). The point that Sang-drax is trying to make is that the first argument to Mid() must be modified in the following cases:
    Code:
    string s1 = "abcdef";
    Mid(s1, 2, 2) = "123";
    if (s1 != "ab123ef") //checking s1, not return value of Mid()
       cout << "incorrect!" << endl;
    So if the first parameter is constant, what do you do? One option is to not let it compile, which in my opinion, limits the functionality unnecessarily.

    gg

  14. #59
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by Codeplug
    What's the status here? We still working on some results??

    gg
    Waiting for golfinguy4's results.

  15. #60
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    golfinguy taking his sweet a$$ time....or too busy golfin.

    gg

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