Search:

Type: Posts; User: deadhippo

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Replies
    22
    Views
    3,571

    Thanks for the feedback. I do hope to live for a...

    Thanks for the feedback. I do hope to live for a long time but I agree. It's probably longer than I need.
  2. Replies
    22
    Views
    3,571

    Thanks. Just figured that out while you were...

    Thanks. Just figured that out while you were posting. It makes sense of course.
  3. Replies
    22
    Views
    3,571

    Now, that I have posted I think I know my...

    Now, that I have posted I think I know my mistake. The statement order was wrong. I should have put the seconds_age = age * 3.156e7; after the scanf. Because I didn't the printf is reading...
  4. Replies
    22
    Views
    3,571

    Short program overflow issue?

    There is a question in my text C Primer + that wants you to convert your age into seconds and it tells you that there are 3.156x(10 to the power of seven) seconds in a year. So I came up with the...
  5. Replies
    8
    Views
    2,085

    Yes, I see it now. Thanks a lot. Unfortunately...

    Yes, I see it now. Thanks a lot.

    Unfortunately I don't feel the explanations are that clear but hopefully it will get clearer as time goes on. Thanks for your patience.
  6. Replies
    8
    Views
    2,085

    Are you saying that the value of lim is 1000? And...

    Are you saying that the value of lim is 1000? And of so where is the connection in the program from the number 1000 to the variable lim?
  7. Replies
    8
    Views
    2,085

    Thanks for your replies. @stevesmithx - The...

    Thanks for your replies.

    @stevesmithx - The program does define MAXLINE as 1000


    #define MAXLINE 1000

    but the function getline uses lowercase so I guess it is not the same
  8. Replies
    8
    Views
    2,085

    K&R variable confusion

    This is a question for those familiar with K&R and for those who don't need to be. On page 29 second edition you can find the following function as part of a program. I don't understand how the value...
  9. Replies
    0
    Views
    1,224

    Program format Question

    FORGET THIS - IT IS WORKING, I left out a part of the program. Sorry.

    Mods: Please feel free to remove this thread.
  10. Replies
    2
    Views
    2,344

    Thanks. You are right. That is exactly what I...

    Thanks. You are right. That is exactly what I did.
    Sorry, I am a beginner and I thought the functions were simply declarations of variables. Thanks for your help and good catch.
  11. Replies
    2
    Views
    2,344

    K&R example help - program error

    Hi,
    I just typed in the example from K&R page 76 and I am guessing I made a typo even though I cannot find it. When I try to compile the program I get some errors and I am hoping that someone here...
  12. Replies
    2
    Views
    3,413

    Thanks for the reply and the advice.

    Thanks for the reply and the advice.
  13. Thanks. I had to study a bit to get my head...

    Thanks. I had to study a bit to get my head around it.
  14. Replies
    12
    Views
    3,050

    Thanks. I'll try that.

    Thanks. I'll try that.
  15. Replies
    2
    Views
    3,413

    Multiple Returns: Am I wrong?

    I was doing another K&R question and again my idea was quite different but I thought I would run it by you bright people.
    The exercise is to rewrite an if else conditional using ?:

    I realize...
  16. Replies
    12
    Views
    3,050

    Thanks Mats, but according to the exercise we...

    Thanks Mats, but according to the exercise we can't use || or &&.
  17. Replies
    12
    Views
    3,050

    Ok, I have another idea. i = 0; loop = 1;...

    Ok, I have another idea.


    i = 0;
    loop = 1;
    while (loop == 1)
    if (i >= lim-1)
    loop = 0;
    else if ((c = getchar()) == '\n')
    loop = 0;
  18. Replies
    12
    Views
    3,050

    Thanks. Back to the drawing board.

    Thanks. Back to the drawing board.
  19. Replies
    12
    Views
    3,050

    K&R solution?

    I was doing one of the K&R exercises which is to write a loop equivalent for the following short program without using || or &&. Usually my solutions are pretty similar to the solution book answer or...
  20. Replies
    12
    Views
    3,671

    Thanks for the reply and the clarification. I'm...

    Thanks for the reply and the clarification. I'm not quite sure what to do with that program yu gave me. Should I use it combination with the previous program or as a standalone. I tried it as a...
  21. Replies
    5
    Views
    6,429

    Thanks again. That code works perfectly for me...

    Thanks again. That code works perfectly for me and with a bit of testing I understand that "ch != '\n'" is the reason it prints the result after enter. Why does this make such a difference?

    Also...
  22. Replies
    5
    Views
    6,429

    Hi, Thanks a lot. You are my saviour. It works...

    Hi,
    Thanks a lot. You are my saviour.
    It works for me too.
    I now understand your CTRL-Z.
    After Ctrl-Z I have to press return.

    I thought that it would print the result immediately after I press...
  23. Replies
    5
    Views
    6,429

    printf not printing

    As with my previous question this is also some confusion about an example or two from K&R. Both of these programs are supposed to produce the same answers and I can follow the code easily enough but...
  24. Replies
    12
    Views
    3,671

    Thanks again.

    Thanks again.
  25. Replies
    12
    Views
    3,671

    Thanks for the reply. I'm not really sure about...

    Thanks for the reply. I'm not really sure about the reasoning but I guess I'll try to just accept it as a fact.
    Why is EOF defined as -1 in stdio.h though?

    Ctrl-C worked for me. Thanks for the...
Results 1 to 25 of 48
Page 1 of 2 1 2