can't figure this thing out...

hi guys,
kinda new at this, just starting learning c++ in college and we were given a few exercises to do.

for some reason i get an error message when i try to run it:
Error 1 error C1075: end of file found before the left brace '{' at 'c:\users\nick\documents\ex8\q13\q13.cpp(57)' was matched c:\users\nick\documents\ex8\q13\q13.cpp 59 1 q13


here is the code:
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*





*/
#include<iostream>
using namespace std;

//declaring functions
void reverse1(char s[]);
void intToStr(unsigned int num, char s[]);

void main()
{
	char testing[]="632459";
	unsigned int num=101010;

	cout<<"The original string of chars is";
	for (int i=0; testing[i]!='\0'; i++)
		cout<<testing[i];
	cout<<endl;

	reverse1(testing);
	cout<<"The reversed string of chars is :";
	for (int i=0; testing[i]!='\0'; i++)
		cout<<testing[i];
	cout<<endl;
	
	intToStr(num, testing);
	cout<<"The string in s[] ouput with an int variable (see code): ";
	for (int i=0; testing[i]!='\0'; i++)
		cout<<testing[i];
	cout<<endl;
}
//this function reverses a string of characters in an array
void reverse1(char s[])
{
	//declaring variables
	char tempChar;
	int i, size;
	
	//inputing the length of s[] into size
	size=strlen(s);

	if (size>1)
	{
		tempChar=s[size-1];	//save the last char in the string for later
		s[size-1]='\0';		//reduce the size of the string by 1 for next function call
		reverse1(s);			//call function again

		for(i=size-1; i>0; i--)	//"move" each char in the string to the right by 1 index
			s[i]=s[i-1];
		s[0]=tempChar;			//input the last char we saved earlier into the first index spot
	}
}
//this function inputs a number represented as an array of characters, and inputs it into an int variable
void intToStr(unsigned int num, char s[])
{
	//declaring variables
	int size;
	char tempChar;
	
	if (num<10)	//reset num to 0 when the recursive action ends (the functions doesn't call itself anymore)
	{
		s[0]=num%10+48;	//input the last remaining digit of num (or only digit) into the first index in the array
		s[1]='\0';
	}

	else
	{
		intToStr(num/10, s);	//call function again
		size=strlen(s);
		s[size-1]=num%10+48;	//input the current single digit into the next spot in the array
		s[size]='\0';	//end the string
	}
}


so i tried finding the problem but couldn't, so here i am.

forgive me for the dumbass remarks... we have to.

thanks in advance!
after changing void main to int main it compiles fine here. Are you sure you posted the same code that's giving you that error?
ctrl+c, ctrl+v.

we don't use "int main", only void..
Well the C++ standard says main must be an int... so that causes a compiler error on many modern compilers. But that's a side point.

You do not have any mismatching braces in that code (which is what the error is suggesting), and if you are sure that is the code you have, then the only thing I can think of is that you are not compiling the code you think you are. Maybe you have one file open, but are actually compiling a different file.

The error is in q13.cpp. Are you sure the code you pasted is from q13.cpp?
yes, 100%. double checked it before i came here.

also, im using visual studio 2012. and as i said, we have to use void main. we can't "gather" information on our own.
i tried copying (ctrl+c, ctrl+v) to a new project and everything, and still.

you're saying there shouldn't be a problem with the code?
Topic archived. No new replies allowed.