Thanks anduril462 I will find out what I can, as that would be really useful to have.
Type: Posts; User: JamesD
Thanks anduril462 I will find out what I can, as that would be really useful to have.
It was the break; ahah, not sure how I missed that one, and to be more specific its UNIX, when I entered man cc I got this, its beyond me..:
Last login: Wed Mar 30 16:55:31 2011 from...
Mine just had whitespace warnings for lines 1-4 lol(I have no idea what that means btw), The compiler I use is called SSH(Secure Shell) If anyone knows how to upgrade to maximum warnings that would...
I am having trouble searching a Linked List for contacts, when the program goes to scan in the last name it reads it in over and over. I am wondering why it doesn't just take the name and continue...
Got it working, thanks for the help.
This accounts for ptrFirst and doesn't re-write ptrNew over and over, however it fails to bring up any results either.. And I'm not sure why
int Load(const char* filename)
{
FILE* infile;...
I looked up putting a whole struct to a file, and tried it out in my program and got this:
int Save(const char* filename)
{
FILE* outfile;
int count = 0; // how many records saved
struct...
Its just basic stuff, ex input:
1
2
point1
8
9
point2
12
34
point3
I am making a program using dynamic memory and was able to successfully code it going into the file, but need help reading it back, I am stuck in the function Load.
#include <stdlib.h>
#include...
Ok, I got it compiled now, it will run and accept 1 list, I added what you mentioned:
void AddToEnd(struct point *ptrN)
{
if(ptrFirst==NULL)
ptrFirst=ptrN;
ptrLast=ptrN;...
Here it is:
#include <stdlib.h>
#include <stdio.h>
struct point
{
int x; //point x
Attempted to re-write the functions to avoid the whole global problem and using case 1 got:
Declared in main:
struct point *ptr=NULL;
case 1:
{
ptr=InputRecord();
AddToEnd(ptr);
break;
Right, I understand that and made this:
void PrintList(struct point *ptrF)
{
while(ptrF != NULL)
{
printf("Label: %s\nx: %d y:%d\n\n", ptrF->label, ptrF->x, ptrF->y);
ptrF =...
Assume it's the exact same but without recursion, when called nothing will print out, and that's got me confused.
Got addtobeginning and input record set now, and I think reset list is working, just gotta work on printlist
void PrintList(struct point *ptrF)
{
struct point *pC = ptrF;
while(pC != NULL)...
How does the prototype look when using struct, I have:
struct point InputRecord(void);
however I think its trying to read it in as a declaration.
These are my codes for adding to the beginning:
case 2:
{
AddToBeginning(ptrFirst,ptrLast);
break;
}
I won't be able to work on it until later today but you helped a bunch. Thanks and I will try to fix up where they point to.
added "break;" to all the cases, switched from void to int main and added the case 0. Thanks CommonTater. Can you see any other problems with it, as I have looked it over again and still can't find...
In this case, the only function I see that needs malloc() is the InputRecord function, I took temp out of global and added that to ResetList and changed from using if to switch statements in main. To...
Yea, I wasn't sure about the allocation thing either, is it best to just use malloc() before the while loop? And I guess it was easy to make global, probably not the best but I think global works.
Added temp globally:
struct point *ptrFirst = NULL;
struct point *ptrLast = NULL;
struct point *ptrNew = NULL;
struct point *temp=NULL;
Modified the function to this:
Took a few mins to look over what you mentioned here is what I came up with:
void AddToBeginning(struct point *ptrF, struct point *ptrL)
{
if(ptrF==NULL)
ptrF=ptrNew;...
It segements when I try to enter a number for input inside main, and sorry about the horrible coding... I really have a lot to learn.
It prints out the menu and I enter the number for the list it...
Yea, I meant to get that done, here it is:
void InputRecord(struct point *ptrNew)
{
printf("Please enter the 2 Data points(x and y):\n");
ptrFirst=ptrNew;
if(ptrNew==NULL)
printf("No...