Thread: parse error ???

  1. #1
    Registered User
    Join Date
    Aug 2003

    parse error ???

    Hi all,
    Trying to figure out some of these errors..Probably going to show how dumb I am again,but this is a simple for loop example and I was just adding system("pause")......and
    #include <iostream>
    using namespace std;

    int main()
    int a,b,s,i;
    cout << "Enter Number: "; cin >> a;
    cout << "Enter the power: "; cin >> b;
    s = 1;
    for (i=1; i <=b; i++)
    s = s*a;

    cout << s << endl;
    system ("pause")
    return 0;


    Compile log:
    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Dev-Cpp\Projects\ProjectCppFiles\SimpleForLoop.cpp" -o

    "C:\Dev-Cpp\Projects\ProjectCppFiles\SimpleForLoop.exe" -g3 -O0 -ansi -g3

    -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward"

    -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    C:/Dev-Cpp/Projects/ProjectCppFiles/SimpleForLoop.cpp: In function `int
    C:/Dev-Cpp/Projects/ProjectCppFiles/SimpleForLoop.cpp:15: parse error before `
    return'Execution terminated

    I get this alot...what's the parse error before on the last line ?? trying to learn these errors why :

    Warning on int main ()
    syntax error before >> ......etc, etc.

    Anyplace I can get a list of these or is it just an experience thing??
    I'm new to c++ and have been using VB....Visual Studio lets you debug before you compile which gives you a shot at figuring out your problems, but it seems here you just have to know the errors cause you can't debug until you can compile...( or am I missing something...there isn't a way to debug before you compile in Dev is there??)
    Appreciate any input.......Thanks! Teeyester

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >system ("pause")
    Notice that just before the return keyword, you have the line you just added. But you didn't terminate the statement, so your compiler reads it as
    system ("pause")return 0;
    It can't parse this, so you get that little error. What it means is that you forgot a semicolon after the system function call.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Aug 2003


    Heh Heh !! your avatar says it all :-))
    Thanks for your time Teeyester

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM