samedi 25 juin 2016

Many syntax errors and stuff I don't even understand

Uhh, started today with C++ and tried to make my own code on how to find the average of the user's grade. I haven't written much, but there are waaay too many errors, and I can't seem to fix them either.

This is the current code:

#include <stdafx.h>
#include <iostream>

void Variables()
{
    // This defines the amount of points per which type of grade.
    int A = 20;
    int B = 17,5;
    int C = 15;
    int D = 12,5;
    int E = 10;
    int F = 0;
}
int main()
{   
    std::cout << "Please type in how many A, B, C, D and E's you have and the amount of courses completed (which you have a grade in)." std::endl;
        // First line which the user types in his A grades and under this, B,C,D and the E.
        int x;
        std::cout << "A: " std::cin << x std::endl;
        std::cout << x  std::endl;

        return 0;   //So far just testing, but I get errors like crazy...
}

When I try to build it, these errors pop up:

1>------ Build started: Project: HelloWorld, Configuration: Debug Win32 ------
1>  HelloWorld.cpp
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(7): error C2059: syntax error: 'constant'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(9): error C2059: syntax error: 'constant'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(15): error C2143: syntax error: missing ';' before 'std::endl'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(15): warning C4551: function call missing argument list
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(18): error C2143: syntax error: missing ';' before 'std::cin'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(18): error C2678: binary '<<': no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)
1>  c:\vc2015projects\helloworld\helloworld\helloworld.cpp(18): note: could be 'built-in C++ operator<<(bool, int)'
1>  c:\vc2015projects\helloworld\helloworld\helloworld.cpp(18): note: while trying to match the argument list '(std::istream, int)'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(18): error C2143: syntax error: missing ';' before 'std::endl'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(18): warning C4551: function call missing argument list
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(19): error C2143: syntax error: missing ';' before 'std::endl'
1>c:\vc2015projects\helloworld\helloworld\helloworld.cpp(19): warning C4551: function call missing argument list
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please help, hehe.

Aucun commentaire:

Enregistrer un commentaire