rendered paste body#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include "error.h"
#include "poly.h"
struct poly_t {
char* exp[10];
char* numb[10];
};
static poly_t* allocatePoly(const char *data){
poly_t *ptr = (poly_t*)malloc(sizeof(poly_t));
int i;
for(i = 0; i < 10; i++){ ptr->exp[i]=NULL; ptr->numb[i]=NULL;}
return ptr;
}
poly_t* new_poly_from_string(const char* theString){
poly_t *ptr = allocatePoly(theString);
char writablestring[strlen(theString)];
strcpy(writablestring, theString);
char *token = strtok(writablestring, " ");
int counter = 0;
char tempchar[20];
while(token != NULL){
if( strpbrk(token, "^") != NULL ){
strcpy (tempchar, token);
ptr->numb[0] = token;
}
printf("[%s]\n", token);
token = strtok(NULL, " ");
counter++;
}
return ptr;
}
void free_poly(poly_t* thePoly){
free(thePoly);
}
char* poly_to_string(poly_t* thePoly){
//Behövs ej göras.
return NULL;
}
poly_t* add(poly_t* a, poly_t* b){
return a;
}
poly_t* mul(poly_t* a, poly_t* b){
return NULL;
}
void print_poly(poly_t* toPrint){
printf("--------"); // HUR SKRIVER JAG UT toPrint->numb & toPrint->exp?
}