My instructor said the way to start this is to use the getline() function from out book, then get the numbers from the line, then have those numbers in matrix form, I do not understand why I would use getline?
//eventually this code should take in a square matrix and from 2x2 to 6x6 //the plan is to get it to read in a line, then get the numbers from the line, //then print out the numbers in a matrix form. That is the goal for today. //later I will try to get the actual matrix part working
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//error list for error checking will need later I guess (from my notes)
#define ENDOFFILE -1
#define TOOMANYNUMS -2
#define LIMIT 256
//functions declared
int get_line(char line[], int);
//main
main(){
char line[255];
int num[6];
printf("Please input numbers %c: ", line);
get_line(line,LIMIT);
}
//functions
int get_line(char s[],int lim){
int c, i;
for (i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
s[i] = c;
if(c=='\n'){
s[i]=c;
++i;
}
s[i]='\0';
return i;
}