почему компилятор ругается на fscanf? Выдает ошибку clang: error: linker command failed with exit code 1 (use -v to see invocation)

210
24 июня 2018, 18:40
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build "/Users/burovano/Desktop/  инфа/лабы 2 сем/лр17/cmake-build-debug" --target 17 -- -j 2
Scanning dependencies of target 17
[ 50%] Building CXX object CMakeFiles/17.dir/main.cpp.o
[100%] Linking CXX executable 17
Undefined symbols for architecture x86_64:
  "_fcloseall()", referenced from:
      _main in main.cpp.o
  "gets_s(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [17] Error 1
make[2]: *** [CMakeFiles/17.dir/all] Error 2
make[1]: *** [CMakeFiles/17.dir/rule] Error 2
make: *** [17] Error 2

//Из текстового файла вводится символьная строка, состоящая из чисел, //разделенных пробелом. Составить программу, которая вводит строку, организует из ее //чисел однонаправленный список, отсортированный по возрастанию их значения, считает // общее количество чисел в списке и количество чисел кратных трем. Вывести на экран // созданный список и всю найденную информацию с соответствующими комментариями. //Если искомых чисел нет вывести соответствующее сообщение.

#include <iostream>
#include <cstdio>
#include <string>
#include <locale>
#include <fstream>
#include <stdlib.h>
using namespace std;
struct numbs
{
    int value;
    numbs *next;
};
numbs *list_add(numbs **phead, int num) {
    numbs *head = *phead;
    numbs *new_word = new struct numbs;
    new_word->value = num;
    new_word->next = nullptr;
    if (head)
    {
        while (head->next)
            head = head->next;
        head->next = new_word;
    }
    else
        *phead = new_word;
    return new_word;
}
void print_numbs(numbs *phead) {
    while (phead)
    {
        cout << "  " << phead->value;
        phead = phead->next;
    }
    puts(" ");
}
int count_num(numbs *phead) {
    int count = 0;
    while (phead->next) {
        ++count;
        phead = phead->next;
    }
    ++count;
    return count;
}
int count_crat_num(numbs *phead) {
    int count = 0;
    cout << "ELements kratnie 3" << endl;
    while (phead->next) {
        if ((phead->value % 3) == 0) {
            ++count;
            cout << "  "<<phead->value;
        }
        phead = phead->next;
    }
    if ((phead->value % 3) == 0) {
        ++count;
        cout << "  "<<phead->value;
    }
    cout << endl;
    if (count == 0)
        cout << "No numbers kratnih 3" << endl;
    return count;
}

void sort_numbs(numbs **phead) {
    numbs *head = *phead;
    int ptr;
    int c = count_num(head);
    for (int i = 0; i <= c; i++) {
        while (head->next)
        {
            if (head->value > head->next->value)
            {
                ptr = head->value;
                head->value = head->next->value;
                head->next->value = ptr;
            }
            head = head->next;
        }
        head = *phead;
    }
}
int main()
{
    setlocale(0, "Rus");
    int _fcloseall( void );
    string gets_s(string);
    char val[120];
    char buf;
    numbs *head;
    int g, i = 0;
    FILE *f = fopen("numb.txt", "w+");
    cout<<"Enter numbers"<<endl;
    gets_s(val);
    while (*(val + i) != '\0')
    {
        fprintf(f, "%c", val[i]);
        ++i;
    }
    i = 0;
    _fcloseall();
    f = fopen("numb.txt", "r+");
    fscanf(f, "%d", &g);
    head = new numbs;
    head->value = g;
    head->next = nullptr;
    while (!feof(f))
    {
        fscanf(f, "%d", &g);
        list_add(&head, g);
    }
    _fcloseall();
    cout << "List from file:"<<endl;
    print_numbs(head);
    sort_numbs(&head);
    cout << "Sorted list:"<<endl;
    print_numbs(head);
    cout << "Amount of elements in the list:  "<< count_num(head) <<endl;
    cout << "Amount of elements kratnih 3:   "<< count_crat_num(head)<<endl;
    system("pause");
    return 0;
}
READ ALSO
Сравнение структур yaml файлов с++

Сравнение структур yaml файлов с++

Нужно с использованием библиотеки yamlh написать код для сравнения yaml файлов

187
Цикл для школьной задачи

Цикл для школьной задачи

Допустим, что задача звучит следующим образом:

213
Qt сделать окно квадратным

Qt сделать окно квадратным

Как сделать MainWindow квадратным? Нужно чтобы окно можно было растягивать, но при этом его высота и ширина оставались одинаковыми

182