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

This is a discussion on Contest Sign-Up Thread: Rewrite Mid() from VB within the Contests Board forums, part of the Community Boards category; I'm in. gg...

  1. #46
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    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,676
    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
    University of Waterloo
    Posts
    1,903

    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 "davt@fsmail.net" 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 davt@fsmail.net is me ...

    DavT

  11. #56
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    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,267
    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,676
    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,676
    golfinguy taking his sweet a$$ time....or too busy golfin.

    gg

Page 4 of 5 FirstFirst 12345 LastLast
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, 01:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21