Что не так с этим? C ++

0

Я занимаюсь программированием с тем, что знаю C++ для практики. Его базовый калькулятор для разработки вещей для MMO, в котором я играю.

Я хочу очистить экран cmd, не используя команды system(). Однако в функции: void clearscreen первая фигурная скобка дает ошибку в 2013 году, ожидая;

Также я знаю, что есть, вероятно, лучшие способы сделать все это, но это то, что я знаю сейчас, и просто получаю некоторую практику. В основном я хотел бы знать, что с этим не так, но отзывы об улучшении этой базовой программы также будут высоко оценены

-Unlogical Логика

#include "stdafx.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <iomanip>

using namespace std;

int main()
{
    double timetotal;
    double timeperinv;
    double xptotal;
    double xpitem;
    double amount;
    double perinv;
    double totalinv;
    double costper;
    double costtotal;

    cout << "=+=+=+=+=+=+=+=Runescape Skill Calculator=+=+=+=+=+=+=+=" << endl;
    cout << endl;

    cout << "How much experience do you want to get?" << endl;
    cin >> xptotal;
    cout << endl;

    cout << "How much does it cost per item?" << endl;
    cin >> costper;
    cout << endl;

    cout << "How much experience do you get per item?" << endl;
    cin >> xpitem;
    cout << endl;

    cout << "How many items can you process in one inventory?" << endl;
    cin >> perinv;
    cout << endl;

    cout << "How long does it take to process one inventory of items?" << endl;
    cin >> timeperinv;

    amount   = xptotal / xpitem;
    totalinv = amount / perinv;
    timetotal = totalinv * timeperinv;
    costtotal = amount * costper;

    void ClearScreen()
    {
        cout << string(100, '\n');
    }

    cout << "=+=+=+=+=+=+=+=Runescape Skill Calculator=+=+=+=+=+=+=+=" << endl;
    cout << endl;
    std::cout << std::setprecision(1) << fixed;
    cout << "The amount of items that you will need to process is: \n" << amount << endl;
    cout << endl;

    cout << "The amount of inventories of items that you will need" << endl;
    cout << "to process is \n" << totalinv << endl;
    cout << endl;

    cout << "The total time it will take to complete processing all" << endl;
    cout << "of the items is: \n" << timetotal << endl;
    cout << endl;

    cout << "The total cost of the items will be: \n" << costtotal << endl;
    cout << endl;

    cout << "The total amount of inventories to process is: \n" << totalinv << endl;
    cout << endl;

}
  • 0
    Вам нужно переместить функцию ClearScreen за пределы функции main ().
  • 1
    Вы не можете поместить функции в другие функции, подобные этим.
Показать ещё 3 комментария
Теги:
visual-c++

1 ответ

1

C++ не поддерживает внутренние функции. Просто определите ClearScreen до и снаружи main().

Ещё вопросы

Сообщество Overcoder
Наверх
Меню