Whats wrong with this code?

I was trying to recreate a program from a book. My IDE is VS express 2010:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// CharacterEncoding -  allow the user to enter a
//						numeric value the print that value
//						out as a character
#include "stdafx.h"
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
[
	// Prompt the user for a value
	int nValue;
	cout << "Enter decimal value of char to print:";
	cin >> nValue;

	// Now print that value back out as a character
	char cValue = (char)nValue;
	cout << "The char you entered was [" << cValue
		<< "]" << endl;

	// wait until user is ready before terminating program
	// to allow the user to see the program results
	system("PAUSE");
	return 0;
]


I'm new so go easy?;)
First, I don't think that we have parameters in the main function.
Apart from that, use curved brackets({}) in place of square brackets ([]) in line 12 and 27.
And http://www.cplusplus.com/forum/beginner/1988/
U can have parameters in the main function. The amount of arguments and the list of arguments. The first argument is the program name. Then optionally if you run from the cmd propt you can add arguments. start someprogram.exe argument1 argument2
@Breadman:
OK! Didn't know about it. Thanks.
@Paradoxx What is going wrong with it? If you are more specific about the error you are getting (runtime, compiler message, ...), we can help you more effectively. If there is a compiler error, copy and paste it on here :)

EDIT: Yes, you can have arguments in the main function (and they word as Breadman said), but equally you can omit them if you don't use them.
Last edited on
Alright It's fixed thanks guys!
It was 3 am in the morning when I was working on that code so I was a little drowsy, cant believe I missed the brackets! Haha, but thanks a bunches.
Last edited on
Topic archived. No new replies allowed.