“Expected expression before ' { ' token”

So I keep on running into this issue when I try assigning values to a int array. I read this one expected expression before '{' token, but I am still confused on why it is showing up in my code. I have a feeling I am initializing and declaring the array incorrectly and that's why it is giving my issues.

So, before main () I am declaring some group of global variables (yes I know this is dangerous, but required for my purpose). With that group of global variables I also want to declare an double array of size 3

double rob_size, rob_tilt;
double rob_leftcolor [3];
double rob_rightcolor [3];

Then in the main function, I am initializing the variables and arrays

rob_size = 1.0;
rob_tilt = 0.0;
rob_leftcolor [3] = {1.0, 0.0, 0.0}; 
rob_rightcolor [3] = {0.0, 1.0, 0.0};

However, I am getting the error message "Expected expression before ' { ' token" at.

First of all, what does that error message mean? Secondly, is that message coming up because I am initializing and declaring the arrays incorrectly?



Best to do the init'ing at declaration time:

double rob_size = 1.0;
double rob_tilt = 0.0;
double rob_leftcolor [3] = {1.0, 0.0, 0.0}; 
double rob_rightcolor [3] = {0.0, 1.0, 0.0};

Only the arrays need to be done that way, but it's best to do them all the same way.

Your alternative is

rob_leftcolor[0] = 1.0;
rob_leftcolor[1] = 0.0;
rob_leftcolor[2] = 0.0;

Need Your Help

VB.Net Checking if DataSet has rows or not

vb.net ms-access

Private Function Gelobee() As DataSet

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.