Search:

Type: Posts; User: Click_here

Search: Search took 0.04 seconds.

  1. Replies
    34
    Views
    5,958

    I think I found what you were talking about here...

    I think I found what you were talking about here - http://cboard.cprogramming.com/c-programming/151288-scanning-new-line.html - I remember it now; how can I forget this classic by soma



    Nominal...
  2. Replies
    34
    Views
    5,958

    Here is one that the whole family can enjoy... ...

    Here is one that the whole family can enjoy...


    char *get_user_input (const char *prompt, char *input_string, size_t input_string_size);


    int main(void)
    {
    char *fname;
  3. Replies
    34
    Views
    5,958

    Initialising is always a good idea. strchr is...

    Initialising is always a good idea.

    strchr is a better idea

    const char * is a better idea

    I don't know where you are seeing Nominal Animal's suggestion, though...

    The extra blank lines...
  4. Replies
    34
    Views
    5,958

    There is one last thing to worry about - That's...

    There is one last thing to worry about - That's the return value from fgets -> If this is NULL, there is a big problem. I've implemented this with a return value. It would also be worth mentioning...
  5. Replies
    34
    Views
    5,958

    If you wanted my advice on how to implement this...

    If you wanted my advice on how to implement this into your code, turn this into a function like this:



    void get_user_input (char *prompt, char *input_string, size_t input_string_size);


    int...
  6. Replies
    34
    Views
    5,958

    I think that you can see that it keeps pulling...

    I think that you can see that it keeps pulling stuff off stdin until either a new line is found, or the EOF.

    "continue" is used in loops to say "start the loop again". It is not needed: However,...
  7. Replies
    34
    Views
    5,958

    Have a look at this example: int main(void)...

    Have a look at this example:


    int main(void)
    {
    char *fname;
    int read_ok;


    fname = malloc(MAXNAME * sizeof(*fname));
  8. Replies
    34
    Views
    5,958

    No, it said

    No, it said
  9. Replies
    34
    Views
    5,958

    You have a choice - char *storage; //...

    You have a choice -



    char *storage; // Create a storage container to store the answer from the user in fgets.
    storage=malloc(sizeof(MAXNAME)); // Allocate memory for the pointer just created...
  10. Replies
    34
    Views
    5,958

    char *storage; // Create a storage container to...

    char *storage; // Create a storage container to store the answer from the user in fgets.

    //Should be

    company *storage; // Create a storage container to store the answer from the user in fgets.
  11. Replies
    34
    Views
    5,958

    char *storage; // Create a storage container to...

    char *storage; // Create a storage container to store the answer from the user in fgets.
    storage=malloc(sizeof(company)); // Allocate memory for the pointer just created with malloc

    ...

    ...
  12. Replies
    34
    Views
    5,958

    Just update the declaration to MAXNAME + 1, not...

    Just update the declaration to MAXNAME + 1, not the value of MAXNAME
  13. Replies
    34
    Views
    5,958

    Give your string an extra character and...

    Give your string an extra character and initialise this last character to '\0'
  14. Replies
    34
    Views
    5,958

    The '\0' character is not being put at the end of...

    The '\0' character is not being put at the end of the string.
Results 1 to 14 of 14