I've expanded my program to do a few more things . I'm a total noob and I'm just messing around with this in hopes of learning some things so please don't make too much fun of me. :p Anyway, I've...
Type: Posts; User: rrc55
I've expanded my program to do a few more things . I'm a total noob and I'm just messing around with this in hopes of learning some things so please don't make too much fun of me. :p Anyway, I've...
Thank you kind sir.
Thanks that did the trick for dirent. As for DIR, I guess you can't access its members directly? No matter, I just changed a few things and used readdir instead.
From wikipedia:
Hi. Noob here just playing around with some things trying to learn. I was wondering if there is a way to print a stationary progress bar onto my console window. I tried ftell() and fseek() but that...
I wrote this test program to familiarize myself with accessing file information but I keep getting a couple of errors I can't figure out. Please help.
#include <stdio.h>
#include...
Here's the macro and suspect function by themselves:
#define putc(x,p) (--(p)->cnt >= 0 \
? *(p)->ptr++ = (x) : _flushbuf((x),p))
int _flushbuf(int c, FILE_ *fp)
{...
I need some help with Exercise 8-3 in The C Programming Language. Basically these first exercises in chapter 8 are dealing with making our own i/o header so we can learn about system calls....
I was wondering about that. I was just about to declare my bit field as a union with an integer in it so I could assign a value to it. Thanks again.
Thank You.
/* Exercise 8-2. Rewrite fopen and _fillbuf with fields instead of explicit bit operations.
Compare code size and execution speed.
*/
/* exercise.8-2.h */
#define NULL 0
#define EOF ...
Ah, thank you. I actually tried defining __USE_GNU because that's what's in my /usr/inlude/string.h
I'd like to know how to use this function in my program. I've included string.h but I still get this warning when compiling.
I'd appreciate some help with this. Thanks.
Actually vars == &vars[0] so ++vars would be the same as &vars[1] and so *++vars == vars[1]. :p
Went back and reread section 5.3 of K&R and found my answer.
Thanks for the replies everyone.
-> has the highest precedence so that should give me the address of my pointer array.
++ and * have the same precedence and associate from right to left so it should increment my array address...
Will someone please tell me why this
*++p->vars = NULL;
gives me this error
vars is an array of pointers to char and p is a pointer to a structure. vars is a member of that structure.
Thank...
hehe ;)
Turns out my input file had more lines than my MAXLINES. Can't believe I overlooked especially considering someone tried to point that out to me! Anyway, sorry for the confusion and thanks for the...
Thank you but I ahve already accounted for this.
Wow silly me. Of course it doesn't work in the loop because the loop still doesnt end.
***
Although I still don't get why getline was counting 1 more the length I wanted, it was an easy fix....
Spoke to soon. I tested the first line out of the loop and it worked. When I use the loop without the "+ 1" in the calloc parameter I still get a segmentation fault in my strcpy line. I'll get back...
Yeah thanks guys. So it turns out my getline function was returning length + 1 the whole time so my while loop never finished and that's why e was so high. For now I just removed the "+ 1" from my...
Yeah that's my version of getline and it does terminate the string. e does go past MAXLINES though.
Thank you both.
I'm still getting a segmentation fault. This time in the strcpy line.
while (l = getline(storeline, MAXLEN))
{
lines[e] = calloc(l + 1, 1);
strcpy(lines[e++],...
Would someone explain to me how to use these? I keep getting a segmentation fault on this line:
strcpy(lines[e++] = calloc(l + 1, l + 1), storeline);lines is a pointer array, storeline is a...
Well all of this is beyond my level of C knowledge. I'll just have to do without this one test for now. Thanks for the help anyway guys.