Thanks for the feedback. I do hope to live for a long time but I agree. It's probably longer than I need.
Type: Posts; User: deadhippo
Thanks for the feedback. I do hope to live for a long time but I agree. It's probably longer than I need.
Thanks. Just figured that out while you were posting. It makes sense of course.
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...
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...
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.
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?
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
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...
FORGET THIS - IT IS WORKING, I left out a part of the program. Sorry.
Mods: Please feel free to remove this thread.
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.
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...
Thanks for the reply and the advice.
Thanks. I had to study a bit to get my head around it.
Thanks. I'll try that.
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...
Thanks Mats, but according to the exercise we can't use || or &&.
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;
Thanks. Back to the drawing board.
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...
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...
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...
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...
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...
Thanks again.
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...