I just ran my debugger and see that now. Thanks a lot! =)
Type: Posts; User: edw211
I just ran my debugger and see that now. Thanks a lot! =)
Would adding a "length == pos" condition like this fix the problem? It should ensure that I've not surpassed the limit. Seems to fix the problem when I test it:
/* getline (MODIFIED): read a...
Ah, right you are. Thanks.
This exercise asks me to rewrite a getline() function. Originally, it stored up to 1000 chars of the line in an array and returned the length of the line. However, the function would not return the...
Ohhhhh, it all makes sense now then. Okay, thanks. I had forgotten about short-circuiting. I was thinking as though everything in the loop condition was carried out with every test.
Right, so in a K&R exercise, I'm supposed to modify this code (which I haven't touched yet). It currently uses the getline() function to read in lines from input, find the longest one, and output it...
No problem. Good luck with the rest of your program.
Someone correct me if I'm wrong, but you don't need to use pointer syntax here because the name of an array itself functions as a pointer. These modifications to your code worked for me:
...
Ohhh yeah, right you are. Not sure why I did that.
And thanks, CommonTater.
One other question. I've been defaulting to using putchar() if I only need a single character because I'm assuming...
Hello all,
I'm currently working my way through the K&R book and am doing all the exercises as I come across them. This exercise asks me to write a program that prints out a histogram of the...
Well, I realized I don't have infinite amounts of horizontal room over which to display every possible length, so I group 20 or more character-long words in the same category. When I display the...
Those functions do look useful for what I'm doing. I think the point of the exercise, though, is to implement a solution using only the tools Kernighan and Ritchie have described so far. I feel like...
Earlier I posted a program as a solution to a K&R exercise that reads a file/text stream and prints out a histogram of number of occurrences of word lengths. I think I've worked out nearly all the...
Seems rather convoluted, but whatever gets you a passing mark, I guess, haha.
And no problem, good luck.
I'm a newbie, but I do notice a few things here:
-you capitalized CalcOut() in your prototype; in your definition, you refer to it as calcOut().
-don't use gets(). You should use the safe...
Ohhh, so that's probably why I often see CR and LF in writing grouped together as CRLF, then? So CRLF means \r\n located in a file written in Windows that got onto a different OS, where just an \n...
If I'm not mistaken, '\r' returns the active position to the beginning of the current line. Just curious, what kind of file or situation would a '\r' crop up in as far as this program is concerned? I...
Ohhhh okay, I gotcha. Yeah, K&R, for this exercise anyway, defines a word loosely as a contiguous group of non-whitespace characters. Not sure what \v is though, will have to look that up or wait...
Didn't know I could initialize the array that way, thanks. I haven't gotten up to <ctype.h> yet. I implemented this using only what I learned in the stuff I've read so far. You're right, I should...
Hello all, I'm on Exercise 1-13 of K&R and am really trying to focus on learning how to come up with a solution that scales well and is easily modifiable. This exercise asks me to implement a program...
Okay cool; I think that's pretty much what I was trying to say, but in less words. Thanks for the confirmation, Salem. Glad I finally understand that.
Cheers =)
-Evan Williams
Hello all,
I'm a college guy trying to bone up on my C skills by progressing through the K&R exercises. Here are the two I am concerned with:
1-8: Write a program to count blanks, tabs, and...