Thread: Help??How to solve this error??

  1. #16
    Registered User
    Join Date
    Jun 2013
    Posts
    20
    Quote Originally Posted by whiteflags View Post
    If it were me I would prepare a smaller array based on the user's choice. To further explain, I would depend a master array of all the CarData from the cars that a user can purchase. From that array, create a smaller array of all the cars that match the make.

    This list can be composed in a loop. I will give you the general idea in pseudocode, but you will have to write it in C.
    Code:
    for each car in inventory:
      if strcmp(car.make, userMake) == 0:
        copy car to filtered list
    It's not the fanciest way, but it works. Once you have that list you can pare it down even further with the user's other specifications by using similar techniques. Or just print out the filtered list with printf().
    This is for Auto Dealership to keep track of what cars they have in stock, not for user purchase.The user is AUTO DEALERSHIP!!

  2. #17
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I see. In that case, absolutely nothing about my suggestion changes. An auto dealership purchases cars from automobile factories. That's all what you're concerned about really means.

  3. #18
    Registered User
    Join Date
    Jun 2013
    Posts
    20

    How to save linked list contents to text file?

    Hi guys, Since my last visit here,I have made few changes in the code,implemented a tree to give users choice,seperated some codes into method and then into different files.I am now running the main program from main method file.The program works well but isn't fully functional.I was looking to display the content of my inventory into a text file from which I plan to use a sorting file to sort the contents.The thing is the method works well but only for one line and console crashes if I try to rerun the method.Also,I don't know how should I sort the contents from text file(What data structure?)
    Edit(After rewriting code into write_text method)
    Code:
    void write_text(){
    	
    		struct node *ptr=start;
    		int j;
    		FILE *ptr_file;
    		ptr_file =fopen("output.txt", "w");
    		while(ptr != NULL){
    			fprintf(ptr_file,"\n%d.\t%s   %s   %d   %s   \n", j,ptr->data.carname,ptr->data.carmodel,ptr->data.caryear,ptr->data.cartype);
    			ptr = ptr->next;
    			j++;
    		}
    		fclose(ptr_file);
    	
    }
    The functions starting with f doesn't work in display method for saving linked list contents to file.


    Can you please help me with this??
    Last edited by i++; 08-09-2013 at 12:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Have an error that i can't solve
    By mdennis10 in forum C++ Programming
    Replies: 5
    Last Post: 04-15-2011, 11:11 AM
  2. how to solve this error msg
    By rhythm in forum C++ Programming
    Replies: 11
    Last Post: 02-08-2008, 10:05 PM
  3. Cant solve this error... please help...
    By Goosie in forum C++ Programming
    Replies: 16
    Last Post: 07-08-2005, 10:32 PM
  4. please help me to solve the error
    By Jasonymk in forum C++ Programming
    Replies: 8
    Last Post: 05-02-2003, 09:08 AM
  5. ^^ help me solve the error
    By skwei81 in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2003, 09:04 AM

Tags for this Thread