Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

C++ syntax error?

syntax syntax error

  • Please log in to reply
10 replies to this topic

#1 DMK741

DMK741

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 03 January 2011 - 07:47 PM

Hello everyone, and happy new year!


I'm trying to code my own version of Tetris using unmanaged C++, and it has been going ok so far, but my project will now not compile because of some odd syntax error. When trying to initialize my arrays in the Shape.h file, every left curly bracket gives an error.

I have hosted the Visual Studio 2010 project here: Tetris.7z

Thank you for any help. This is probably a simple mistake, as I am new to C++.
  • 0

#2 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 03 January 2011 - 09:23 PM

Try getting rid of the dereferencing asterisks.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#3 DMK741

DMK741

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 03 January 2011 - 09:35 PM

didn't work.
  • 0

#4 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 03 January 2011 - 09:37 PM

I can't really test it right now, but try doing the entire thing in one assignment. There shouldn't be any need for dereferencing or indexing.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#5 DMK741

DMK741

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 03 January 2011 - 09:51 PM

Why no dereference operators? My variable is of type "pointer", so don't I need to have an asterisk before it if I assign a value to the memory it points to? And since it's a pointer to a pointer to a pointer, don't I need 2 asterisks (considering that I have "[]" which is really just a dereference operator with a shift)?

btw, I tried it anyway and it still gave me errors.

Edited by DMK741, 03 January 2011 - 10:26 PM.

  • 0

#6 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 04 January 2011 - 11:33 AM

This works:
int chachacha[][2][4] = {{{1,2,3,4}, {5,6,7,8}}, {{9,10,11,12},{13,14,15,16}}};

  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#7 DMK741

DMK741

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 04 January 2011 - 07:25 PM

This works:

int chachacha[][2][4] = {{{1,2,3,4}, {5,6,7,8}}, {{9,10,11,12},{13,14,15,16}}};


no it doesn't. I get the same error, along with a new one for not having an index in that first set of brackets.
  • 0

#8 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 04 January 2011 - 07:35 PM

It compiles just fine with GCC. What compiler are you using?
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#9 DMK741

DMK741

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 04 January 2011 - 07:38 PM

Visual Studio is my IDE. idk what the name of the compiler is.

Try messing with pointer arrays like I did. See if you can get anything useful out of that.
  • 0

#10 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 04 January 2011 - 07:39 PM

Okay, but it'll have to wait until tomorrow night for me. Not sure about the time difference, though.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#11 DMK741

DMK741

    CC Newcomer

  • Just Joined
  • PipPip
  • 23 posts

Posted 04 January 2011 - 07:41 PM

that's ok. I appreciate it.
  • 0





Also tagged with one or more of these keywords: syntax, syntax error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download