Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

sparse matrix and linked lists

  Asked By: Won Wook    Date: Jun 13    Category: C Programming    Views: 1282
  

Hey guys,

I'm trying to make a function that reads a sparse matrix off a textfile and makes a linked list of that matrix

I want it to use <stdio.h> and a node should be in a style like

struct node {
int row;
int col;
int elem;
struct node *down;
struct node *right;
};

Reading off a text file would be like

int linkedlist(void) {
int i, j, row, col, val;

FILE *file = fopen("matrixA.txt", "r");
fscanf(file, "%d", &row);
fscanf(file, "%d", &col);

for(i=0; i<row; ++i) {
for(j=0; j<col; ++j) {
fscanf(file, "%d", &val);

and then putting whatever value into the linked list.

I'm struggling to make this function, and to figure out the starting address of this list.

Please help!

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on sparse matrix and linked lists Or get search suggestion and latest updates.




Tagged: