Okay, so this is basically how loose ends are tied anytime a non-void function is called? I added:
if (fgets_ptr==NULL) return -1
if (fgets_ptr!=NULL) return 1;
Suppose I change the call...
Type: Posts; User: SiliconHobo
Okay, so this is basically how loose ends are tied anytime a non-void function is called? I added:
if (fgets_ptr==NULL) return -1
if (fgets_ptr!=NULL) return 1;
Suppose I change the call...
I'm wondering if anyone can recommend a book(s) on more specific aspects of C programming, like windows programming, APIs for GUIs and whatnot. Cheers.
Okay, I'm a newbie as I've said and I'm pretty damn pleased that the prog is working the way I want it to. I'm still a long way from knowing how to optimize or maximize safety or whatever but I am...
fgets_ptr = fgets(string, size, stdin);
Thanks. And what's that other warning about return path? What compiler are you using Elysia? It compiled clean in DevC++ 4.9.9.2.
Sweet. Thanks for your help and patience everyone! I finally have it working with the following code:
void input () /* gets an entry from the...
Yeah, my original version passed the structure but I couldn't figure out how to pass different pieces of the structure without writing a different version of get_input for each array in the...
Hmmm, the structure components are all char arrays so I tried this in input:
char *string;
string = get_input (prompt1, 50);
entry.name = *string;
free...
Okay, thanks. Just to make sure I have this straight, malloc assigned variables persist globally until freed?
I've added this line to the initialization of get_input:
pointer = (char*)...
Hey Folks,
I'm getting an "incompatible types in assignment" error and warning as well as a "return makes pointer from integer without cast" warning. Yes, I'm a newb. I've been reading the...
Okay, thanks Todd and Elysia for the detailed explanation. I've simplified the program and I believe my declaration, call and function now match.
char get_input (char[26]);
get_input...
Okay. I read them but no light bulbs are coming on atm. If I could understand the errors that would probably help. The only one I'm familiar with is the undeclared variables error but I don't see why...
Thanks for the replies. Todd: I know you gave the exact working code but I wanted to write my own based on what I learned from your example rather than simply copy/paste. I have now got the get_input...
Yes, only once in each run through the do-while. Thanks. Now I only have to hit enter twice instead of 3 times :P Could it be something to do with :
while((junk = getchar()) != '\n' && junk !=...
Hmmm, so what do I return if I want this to compile and run without crashing if fgets returns NULL?
Also, when I remove this line the code compiles but I get prompted for a name and must hit...
Hey Folks,
Anyone know why I'm getting an "incompatible types in return" error for :
if (fgets_ptr == NULL) return -1; in Dev C++ 4.9.9.2?
Even when I remove the line, the function still...
Rawk. This thread helped a lot. Thanks.
I realize I could do it either of the other two ways you suggested but I'd like to figure out what the -entry means in that line. What's an "index" in this case? I'm thinking in terms of a minus...
Yeah, that's what I was going for, thanks for fleshing it out Todd and matsp. I'm still not quite sure what this line does at the end of the do blocks in Todd's code:
if (fgets_ptr==NULL) return...
Wowzers, thanks for the very informative replies. I'm still boggling at how much this code (or something like it) increases both the size and complexity of my once innocent little prog... growing...
Okay, I just read about
while((ch = getchar()) != '\n' && ch != EOF);
In the recent Explanation of a Function thread and some bells are ringing. I'd still appreciate comments on my newline...
Hey folks,
I have first concentrated on writing functional code that does what I want. However, I have read the FAQ and numerous posts about portability issues with fflush so I have now attempted...
Rock. Thanks foxman. That semicolon has been a thorn in my side long enough.
Thanks for the reply. This is really stumping me. I'm using Dev C++ 4.9.9.2.
Hey Folks,
This recursive menu function is supposed to only list the options once, before menu_shown is incremented. However, the options are still being listed each time I default. Does anyone...
Thanks matsp for the fastest reply ever. I added another typedef line and removed the type declaration in the call to output and it works fine. Cheers.