Aha, that makes sense (top-down). Thank you.
Type: Posts; User: patricio2626
Aha, that makes sense (top-down). Thank you.
Hello again,
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void insert(struct personStruct **root, char firstName[], char lastName[]);
void display(struct personStruct **root);
Aha, so, only use free() when I want to destroy my list. I didn't realize that that's what I was doing. Also, when I put the function prototypes below into the file just below the include...
Hello again,
Ugh, now I remember why I quit C++ and never looked back after the transition to Java. DS&A with C++ was next to impossible, because I didn't have a firm grasp on pointers. I...
First, excuse me; I should have said never evaluates to null :o. The root is skipped when inserting, and display() causes an infinite loop in which the new value is displayed. Code below:
...
Actually, looking at limits.h in an attempt to answer a question from another poster, I see that my library is indeed GCC :)
Looking at it, you are going up to n=52, so I think you're pretty much forced to use a double if you want anything above 10^9 or so. MAX_DBL in float.h is going to be the max value a double can...
Are you sure that this happens on the first iteration? Just curious, what happens if you put a fflush(stdout) after the printf("%d", v) statement, and change it to printf("%d", n)? Maybe it's...
Just curious, what is the value of tmpxp2 at that point in your debug?
Okay, looking at your screenshot, maybe this is some kind of numeric overflow. Look at the value of tmpxp1, and look at the likely min value of int: –2147483647 – 1.
Interesting. Would you mind posting the new code?
Probably because the possible range of values is so large. Maybe you could cast back to int or long?
*Edit : Nyah Check beat me to the explanation :)
Look up pow. And yes, exc_i386_div = division by zero.
Hello again,
Eclipse with MinGW GCC compiler, Windows 7 - what do you mean exactly by 'library'? I did fix the dereferencing (thank you - it makes sense that a pointer to a pointer should be...
Thank you. Any idea why root is still evaluating as NULL here?:
#include<stdio.h>
#include<stdlib.h>
struct personStruct{
char first[999];
Okay, now, a couple of follow-up questions:
1) I know that memcpy told me to use stderr, but I was experimenting with omitting fflush(stdout) just before scanf() statements, and no, no text is...
Indeed, the below works. Thanks for the tip, memcpy.
#include<stdio.h>
#include<stdlib.h>
struct personStruct{
char fn[999], ln[999];
struct personStruct *next;
}*root = NULL;
Okay, this makes sense: since pointers contain addresses, I was simply changing the value of what was stored in that address, and since I had fn and ln point to firstName and lastName in each...
Okay, I'm just trying to insert values into a linked list (structs), and I must be doing the assignments wrong, but I can't see what it might be. Is it not simply tempPtr = tempPtr->next ? Can...
Yep, apparent improper use of ctrl + c :biggrin:
Sho' nuff! :) The below works, thank you!
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
char c1[888] = "hello!";
Hello all,
I'm trying to create a simple routine where I transform the individual characters of a character string to uppercase. I'm trying to figure out why I can dereference individual...
Thanks for the explanations and patience, guys! My new text is much better but still skips a lot of details,
Sorry, one more thing... just so I'm clear on this, why is, for example, below, the newString object passed by reference, and not by value if it's not being modified directly?
bool...
Thanks! Excuse the dumb questions; I'm on my second data structs book, because the first one confused me so much, but... when would I ever have newString& as a return type? Is there a case where I...