Hi there i have a txt file containing these variables
anil just_go_with_it 5
betty the_dark_knight 3
anil source_code 3
carrie just_go_with_it -3
anil paranormal_activity -5
doug the_dark_knight 5
betty shawshank_redemption 5
carrie source_code 1
betty paranormal_activity 5
carrie shawshank_redemption 5
doug shawshank_redemption 3

what im trying to do is to sort them in a 2d integer array, where the name of the person is the row and the name of a movie is a column and the numbers are at the locations of the row and column...

can someone help me out cheers..

Edited by monty486: n/a

6 Years
Discussion Span
Last Post by monty486

Names and movies are not integers. Perhaps you should consider another data structure. Maybe an array of something like:

struct {
   char * name;
   char * movie;
   int rating; 

what im actually trying to do is, set the name of a person and the movie a number , which represents the row and cols. so for the example above there is 4 rows, indicating to 4 names, and there are 5 columns, which are the 5 movies, and in that i want to store the numbers shown in the example


Do you know the number of names/movies in advance or do you need to get that from the file?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.