scanf leaves "\n" (the enter key or newline character), in the buffer after it reads it. Your next call to read the buffer, i.e. via gets, sees a newline chara and returns straight away. You need to...
Type: Posts; User: AAnderson
scanf leaves "\n" (the enter key or newline character), in the buffer after it reads it. Your next call to read the buffer, i.e. via gets, sees a newline chara and returns straight away. You need to...
Yeah, I'm confused as well, if you want to print the bytes themselves then you'll have to loop through your buffer (or the file) and print those elements.
Hmm, as a noobish question, is the benefit of maintaining a separate structure for first and last items faster look up times? I looked over this link: C Linked List Data Structure Explained with an...
I'm following along this topic with interest. Would the answer to this particular walking be recursive call?
The first time through, your program is going to try access source outside its bounds. j is initialised to 0, you call j-1 which will be before the start of your source string, you have no guarantees...
Hmm, just wondering why you strcpy your string into an address 1 ahead of the one you just allocated?
Yeah, you don't just "get" programming, much like you don't just "get" spanish or any other language. You have to be playing around in your own time, making things, breaking things, etc. Much like...
Why do you have the big if statement checking bossDirection and assigning newDirection if newDirection always = bossDirection?
Also, why use pragma omp (not that I really have any idea what that...
You've already identified your problem, so how do you stop your loop iterating over the edge of your array? Also, write out what you think your algorithm will do for a very short array (say 5 long),...
What happens if instead you tell temp to grab a[i+1], or a[i+10] etc?
It looks like you're printing your array of character elements as if they were integers. I'm surprised you're not segfaulting. You should use %c as your format element if you want to print characters.
You shouldn't need a second loop for that. Think about how you can do it by manipulating your index (your i) to access different elements during each loop iteration. Just use your temp to hold one of...
Hi Phil,
It really depends how you want to swap the values, do you want to permute them randomly? Do you want swap every second value?
On a tangent, you should iterate from i = 0 to i < size. I...
Thanks for the info guys.
Sorry I can't answer your question off the top of my head, but in my admittedly very short experience with C, I haven't seen the practice of declaring your function inputs outside the curly bracers,...
What laserlight said, also, if you really want to use a number. You could just check if(aussie), then any number except 0 will give you a true result.
Hey mate, I'm an absolute baby at C but there's one thing I noticed.
In the insert_at_end function:
You declare *st but you don't initialise it before passing it to the strlen function. You...
Taking my thoughts on this a little further, I don't know why I didn't see that I could just store the information as text strings and then parse them for the ID information as I reload them.
...
Nope, purely unfamiliarity with best practices. I just took a stab using the initial program as a base (which did have statically allocated arrays). The problem is simplified if I remove the...
Ahhhhhhhhhhh, light bulb!
I had wondered about that, do you have any suggestions for how I should approach the problem then? Re-link the pointers after reading in raw data? Avoid writing the...
What you say makes sense, but fwrite doesn't actually write the pointer out. From the linux man pages:
As I understand it, those function are writing a block of memory of a certain size to...
Can you elaborate on what you mean? If you've followed this thread (I don't expect you to have, it's long and there's a lot of tangential debate). You'll know that this task I've set myself is a...
Ahhhhh, I think I've cracked it. I was using sizeof(char*) instead of sizeof(char). Using sizeof(char) returns no errors except for that very last one about unintialised bytes, which I think is...
Good point, I made the modification but it hasn't fixed the problem. The output is exactly as before. Same error, same mem location.
Hi Jim,
The first line of the output is actually how the program was launched, i.e. "... ./ex17 alloctest4 c". There is no input file as such, it is created by Database_open (or opened if the flag...