Using a linked list globally and File I/O

This is a discussion on Using a linked list globally and File I/O within the C Programming forums, part of the General Programming Boards category; You are using break/continue in a non-traditional way, and I don't think you actually mean to do it that way, ...

  1. #46
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You are using break/continue in a non-traditional way, and I don't think you actually mean to do it that way, as there is so little benefit and huge increase in confusion from it [in fact, I think most of your confusion stems from this].

    Change ALL of your continue to break.

    Then use do - while instead of for(;, and set a flag based on your choice2 input.

    However, you also compare choice2 with the string "y" - this will not work - choice2's location in memory will never ever match the string "y" [at least not and also function correctly with the fgets() that you are using]. You need to use strcmp or just use a compare of the first character of your string.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #47
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,013
    Code:
    if (choice2=="y") break;
    OK, so choice is char* and "y" is char*, so you're basically comparing pointer vs. pointer, and that's why it doesn't work.
    If you need to compare a char against a char, you would do choice[n] = 'n' as you did. If you need to compare a string against another string, you need to use strcmp.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linked list versus array
    By FoodDude in forum C++ Programming
    Replies: 18
    Last Post: 08-22-2005, 11:57 AM

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