Thread: Why oh why strcpy?

  1. #16
    Banned
    Join Date
    Aug 2017
    Posts
    861
    so you're trying to get it to do this?
    Code:
    (Debug) star 1 0, star 2 4, distance 7.071
    The closest pair of stars are no. 0 and 4
    They are 7.071 light years apart
    Would you like to name this pair (y/n)? 
    y
    Enter your full name: 
    name1
    (Debug) name1
    Enter your spouse' full name: 
    no
    Congratulations! A pair of stars has been named after you and your spouse
    >>> show
    got command show
    Enter your full name: 
    no
    name1 & no

  2. #17
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    To be fair, the command was actually "bang " with a number following. You didn't do that when you tested, hence the problem.
    well that explains what that was for ---> # .. silly me.
    thanks for that clarification. I guess I should have read the documentation on symbolic notation.
    Last edited by userxbw; 12-11-2017 at 10:37 AM.

  3. #18
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Quote Originally Posted by userxbw View Post
    so you're trying to get it to do this?
    Code:
    (Debug) star 1 0, star 2 4, distance 7.071
    The closest pair of stars are no. 0 and 4
    They are 7.071 light years apart
    Would you like to name this pair (y/n)? 
    y
    Enter your full name: 
    name1
    (Debug) name1
    Enter your spouse' full name: 
    no
    Congratulations! A pair of stars has been named after you and your spouse
    >>> show
    got command show
    Enter your full name: 
    no
    name1 & no
    Yes, I am, and weirdly it doesn't seem to make much of a difference whether I use bang or not. If I use bang, there are just more stars, that's all it seems to mean.

  4. #19
    Registered User GeorgeIO's Avatar
    Join Date
    Nov 2017
    Posts
    33
    Well, ideally the show command should actually print the names under the stars on the actual frame buffer, ie similar to the draw command but including the names of the pair you want to show. But I have no idea how to go about implementing this. So just displaying the names like in your example would be a start.

    And when using the pair command, the program should display the information relating to any pairs that have already been named. Make sense?

    show ex:
    Why oh why strcpy?-showexample-png

    pairs ex:
    Why oh why strcpy?-pairsexample-png

    Oh, and save and load should also work in an ideal world. Any pointers on where I've gone wrong in my code for those two functions? Although the other things I've asked are probably more important. Thanks for all the help guys.
    Last edited by GeorgeIO; 12-11-2017 at 10:47 AM.

  5. #20
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by GeorgeIO View Post
    Well, ideally the show command should actually print the names under the stars on the actual frame buffer, ie similar to the draw command but including the names of the pair you want to show. But I have no idea how to go about implementing this. So just displaying the names like in your example would be a start.

    And when using the pair command, the program should display the information relating to any pairs that have already been named. Make sense?
    in your requirement to print the names I have to give it a name so it will print the stars. to get more to print out, that would mean I'd have to be asked every time I want to print the name of the named stars which requies one to do what? utilizing the persons (users) memory hopefully it is a photo memory, and just ask again and again until everything is printed out. providing you keep track of that.

    remove that an just loop everything to the screen in where you keep the already named and see how that turns out.

    I am just speaking in logical terms and not looking at what you've coded.
    Last edited by userxbw; 12-11-2017 at 10:49 AM.

  6. #21
    Banned
    Join Date
    Aug 2017
    Posts
    861
    as far as this big bang thing you got going on with this, why are you even asking for a number of stars? logically that would be determined by the "big bang", yes?

  7. #22
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Yes, I am, and weirdly it doesn't seem to make much of a difference whether I use bang or not. If I use bang, there are just more stars, that's all it seems to mean.
    I just replaced memcopy with strcpy ... the question posted gives the answer but he asks why oh why strcpy then misleads with the question posted within the context of this post.

    as far as what you said about the rest I am now in a state of confusion again. why oh why?

    If I use bang, there are just more stars, that's all it seems to mean.
    how do you just use the word bang and get it to work, did you remove the requirement to add a number for stars?

  8. #23
    Registered User
    Join Date
    Dec 2017
    Posts
    1,626
    pairs uses i before it's initialized.
    And it's more important to use -Wextra (a.k.a., -W) than -pedantic, along with -Wall.

  9. #24
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by john.c View Post
    pairs uses i before it's initialized.
    And it's more important to use -Wextra (a.k.a., -W) than -pedantic, along with -Wall.
    so using all three produces what results over just -W and -Wall ?
    Code:
    gcc -Wall -Wextra -Wpedantic -lm -o "GeorgeIO_Big_Bang_sim" "GeorgeIO_Big_Bang_sim.c" (in directory: /home/userx/bin)
    -lm is just a fail safe when people use the math header when it is actually really needed.

  10. #25
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by GeorgeIO View Post
    Well, ideally the show command should actually print the names under the stars on the actual frame buffer, ie similar to the draw command but including the names of the pair you want to show. But I have no idea how to go about implementing this. So just displaying the names like in your example would be a start.

    And when using the pair command, the program should display the information relating to any pairs that have already been named. Make sense?

    show ex:
    Oh, and save and load should also work in an ideal world. Any pointers on where I've gone wrong in my code for those two functions? Although the other things I've asked are probably more important. Thanks for all the help guys.
    It puzzles me to know that you know how to store the information but have no idea how to get it out again. when it looks like you know how to loop and printf and use if statements and such programming things as those.

  11. #26
    Registered User GeorgeIO's Avatar
    Join Date
    Nov 2017
    Posts
    33
    I had turned on -Wextra too, but does it stand that by using -W there's no need to use -Wall?

    And user, the number in the bang command was part of the requirements of this particular assignment. It wasn't up to me. And the thing is, I've only been programming for about 6 weeks. So my bad if I can't do everything really well just yet. Like I said, I thought my code for the pairs command was logically okay, but it's obviously not - so that's why I asked for help.

  12. #27
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Quote Originally Posted by userxbw View Post
    I just replaced memcopy with strcpy ... the question posted gives the answer but he asks why oh why strcpy then misleads with the question posted within the context of this post.
    Because this should be sufficient?
    Code:
    /*
    !! Fixing the following:
    main.c: In function 'write_at':
    main.c:308:22: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
        fbuffer_arr[x][y] = str;
                          ^
    */
    
     strcpy (fbuffer_arr[x][y], str);
    I'm not sure I understand the sudden controversy or the confusion over this. I attempted my best to be clear. I covered the warnings in the post in order as well. I don't really know how else to help you understand.

    as far as what you said about the rest I am now in a state of confusion again. why oh why?

    how do you just use the word bang and get it to work, did you remove the requirement to add a number for stars?
    It's still "bang #". Sorry. I meant use bang in the same way someone might say "use the gcc command to compile" and provide no more details. Unless you are in the habit of never leaving some things implicit.
    Last edited by whiteflags; 12-11-2017 at 11:56 AM.

  13. #28
    Registered User GeorgeIO's Avatar
    Join Date
    Nov 2017
    Posts
    33
    whiteflags, your posts have been very helpful. I really appreciate it!

  14. #29
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Because this should be sufficient?
    Code:
    /*
    !! Fixing the following:
    main.c: In function 'write_at':
    main.c:308:22: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
        fbuffer_arr[x][y] = str;
                          ^
    */
    
     strcpy (fbuffer_arr[x][y], str);
    I'm not sure I understand the sudden controversy or the confusion over this. I attempted my best to be clear. I covered the warnings in the post in order as well. I don't really know how else to help you understand.


    It's still "bang #". Sorry. I meant use bang in the same way someone might say "use the gcc command to compile" and provide no more details. Unless you are in the habit of never leaving some things implicit.
    apples and oranges but enough of this confusion conversation, on with his program.

  15. #30
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Quote Originally Posted by userxbw View Post
    apples and oranges but enough of this confusion conversation, on with his program.
    We've been talking about his program the entire time, unless I'm alone in that. And as far as "apples and oranges" go have you ever thought that maybe you were being unclear?

    I'm not misleading anyone, and I resent you casually implying that I am.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2010, 07:42 AM
  2. strcpy
    By bobbelPoP in forum C++ Programming
    Replies: 4
    Last Post: 07-28-2008, 08:44 PM
  3. strcpy
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 08-01-2002, 01:39 PM
  4. HELP!! strcpy
    By abbynormal87 in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2002, 07:34 AM

Tags for this Thread