fourthdimension
September 10th, 2007, 05:07 PM
Hey All
I just wrote my first, very simple program, and I get an error when compiling it.
Here's the source:
//This is an original test program made to add any given number to 10
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
cout<< "this program adds ten to any value you enter. please enter a number";
//define the input variable
int inputNumber;
cin>> inputNumber;
//define the output
int outputNumber
//now add ten to the value
outputNumber = inputNumber + 10
//now give the output...
cout<< "the new value is"
cout<< outputNumber
}
...and here's the error:
mymachine:~$ g++ -o TestAddingProgram '/home/secondgenesis/Desktop/Programming/Test Programs and source/Original test adding program.cpp' /home/secondgenesis/Desktop/Programming/Test Programs and source/Original test adding program.cpp: In function ‘int main(int, char**)’:
/home/secondgenesis/Desktop/Programming/Test Programs and source/Original test adding program.cpp:24: error: expected initializer before ‘outputNumber’
Also, I've seen this line in nearly every C++ source I've looked at so far; can anyone tell me what it does? It looks like it initializes the variable "main" and includes certain libraries, but I don't entirely understand what all of it means.
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
Thanks a lot! I probably wouldn't even have gotten this far on my journey into coding if it weren't for the Ubuntu community.:)
I just wrote my first, very simple program, and I get an error when compiling it.
Here's the source:
//This is an original test program made to add any given number to 10
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
cout<< "this program adds ten to any value you enter. please enter a number";
//define the input variable
int inputNumber;
cin>> inputNumber;
//define the output
int outputNumber
//now add ten to the value
outputNumber = inputNumber + 10
//now give the output...
cout<< "the new value is"
cout<< outputNumber
}
...and here's the error:
mymachine:~$ g++ -o TestAddingProgram '/home/secondgenesis/Desktop/Programming/Test Programs and source/Original test adding program.cpp' /home/secondgenesis/Desktop/Programming/Test Programs and source/Original test adding program.cpp: In function ‘int main(int, char**)’:
/home/secondgenesis/Desktop/Programming/Test Programs and source/Original test adding program.cpp:24: error: expected initializer before ‘outputNumber’
Also, I've seen this line in nearly every C++ source I've looked at so far; can anyone tell me what it does? It looks like it initializes the variable "main" and includes certain libraries, but I don't entirely understand what all of it means.
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
Thanks a lot! I probably wouldn't even have gotten this far on my journey into coding if it weren't for the Ubuntu community.:)