LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2006, 01:13 AM   #1
RHLinuxGUY
Member
 
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889
Blog Entries: 1

Rep: Reputation: 30
expected primary expression before... Uint character question.


I have been having problems with the following code:

Code:
				
RndHist = Random;
printf("\nFIGHT!\n");
text[] = "Fight"; //text[] is actualy: Uint16 text[250];
display_font(225, 420, 16, 0, 0, 0);
when I compile it using my make file it spews out this error:

Code:
george@georgescomp1:~/cfiles/George Lair/050606$ make
g++ -c `sdl-config --cflags` main.cpp
main.cpp: In function ‘void FightChk()’:
main.cpp:95: error: expected primary-expression before ‘]’ token
make: *** [main.o] Error 1
george@georgescomp1:~/cfiles/George Lair/050606$
I have tried the following (the ones that are coming to mind):

text[] = {'F','i','g','h','t','\0'};
text[250] = {'F','i','g','h','t','\0'};
text[250] = "Fight";

Does this have to do with Uint16? I could not get a straight to the point answer online through google or yahoo, or at cplusplus.com or cprogramming.com. Uint16 is needed in the SDL_ttf function TTF_RenderUNICODE_Solid(font,text,color). I could probably easily use another function, but I would like to see what is going wrong with this before I move on. I have another question regarding this but I have to hit the sack and also I'm in a fog so it is not coming to mind how I phrase the question. I'll get back this tommarow.(051106)

PS: If this question was too vague, such as not enough information or if I contradict myself or etc in any way, please tell me so I can fix the problem. I do not like retarded threads/posts, but I do what I hate at times and I like to correct them.
 
Old 05-12-2006, 05:46 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
If you wish to use an initialiser then you need to do it when text is declared, although why your are using Uint16 rather than a char I don't know?

char text[] = "I need to be defined here";

but if you try to do the following:
char text;
text[10];
you'll get an error because statement 1 says text is a single character, whilst statement 2 contradicts that by trying to say that it is an array of characters.
 
Old 05-12-2006, 09:38 AM   #3
RHLinuxGUY
Member
 
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889

Original Poster
Blog Entries: 1

Rep: Reputation: 30
The reason why I use Uint16 is because TTF_RenderUNICODE_Solid requires it as one of its arguements, which is where you input text.
 
Old 05-12-2006, 12:08 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Okay but to assign the values you need to do it one at a time:

text[0] = 'F';
text[1] = 'l';
text[2] = 'i';
text[3] = 'g';
text[4] = 'h';
text[5] = 't';
text[6] = '\0';
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression question gauge73 Linux - General 5 10-28-2005 11:33 AM
Regular expression question gauge73 Linux - General 2 10-28-2005 09:32 AM
Reg Expression Question windisch Programming 6 10-04-2005 11:08 AM
regular expression question zero79 Linux - Software 1 07-11-2005 07:03 PM
Error upgrading kernel, /sbin/mkinitrdi integer expression expected amp2000 Linux - General 2 12-05-2003 05:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration