возможно, еще одна глупая ошибка, но я действительно не могу обдумать это.
Я пишу базовый класс полиномов, и моя программа неожиданно завершает работу при вводе пары целых чисел. Я пытался найти решение, но не смог найти его: /
код:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Homework.h"
#include "Fraction.h"
int main()
{
//Input from user
int degree, i;
printf("Insert the degree of the polynomomial: \n");
scanf("%d", °ree);
//Get the coefficcients
struct fraction *bucket = malloc((sizeof(struct fraction))*(degree + 1));
int num;
unsigned int den;
for(i = 0; i < degree + 1; i++)
{
num = 0;
den = 1;
printf("Insert the coefficcient of degree %d, first num and afterwards
the den \n", i);
printf("Numerator:\n");
if(scanf("%d", &num) != 1)
printf("Input error\n");
printf("Denominator:\n");
if(scanf("%u", &den) != 1)
printf("Input error\n");
//struct fraction temp = {num, den};
//memcpy(&bucket[0], &temp, sizeof(struct fraction));
}
//Check insertion
printf("Test\n");
//print_fraction(bucket[0]);
}
Программа завершает работу еще до печати «Тест», и для ввода я использую номер ввода + клавиша ввода.
Большое спасибо за любую помощь!