Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

paulmcco

macrumors newbie
Original poster
Jul 26, 2011
5
0
Hello, I get this error from code within a header file...any ideas?

ScorePlayerMatch.h:25: error: stray '\20' in program
ScorePlayerMatch.h:25: error: parse error before numeric constant


Code:
#include <Carbon/Carbon.h>
struct scoreMatch {
	double scoreArr[5][2];
}ScorePlayerMatch();

scoreMatch ScorePlayerMatch(double pair, double threeKind, double twoPair, double fourKind, double fullHouse, double pairCard, double secPairCard, double threeKindCard, double highC, double lowC)
{
	scoreMatch infunc;
	infunc.scoreArr[0][0] = pair; 
	infunc.scoreArr[0][1] = 2.0*pow(10.0,6.0) + (pairCard * 10000.0) + (highC) + (lowC/100.0);
	infunc.scoreArr[1][0] = threeKind; 
	infunc.scoreArr[1][1] = 4.0*pow(10.0,6.0) + (pairCard * 10000.0) + (highC) + (lowC/100.0);
	infunc.scoreArr[2][0] = twoPair; 
	infunc.scoreArr[2][1] = 3.0*pow(10.0,6.0) + (pairCard* 10000.0) + (secPairCard*100.0) + (highC) + (lowC/100.0);
	infunc.scoreArr[3][0] = fourKind; 
	infunc.scoreArr[3][1] = (8.0*pow(10.0,6.0)) + (pairCard * (1.0 * pow(10.0,4.0))) + (highC) + (lowC/100.0);
	infunc.scoreArr[4][0] = fullHouse; 
	infunc.scoreArr[4][1] = 7.0*pow(10.0,6.0) + (pairCard*10000.0) + (threeKindCard*100.0) + (highC) + (lowC/100.0);
		
	return infunc;
}
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
One idea: don't write functions in header files.

Another:
od -ta thefile.h
Look through the output for the rogue character, then remove it.

-Lee
 

lloyddean

macrumors 65816
May 10, 2009
1,047
19
Des Moines, WA
Code:
#include <cmath>

struct scoreMatch {
    double scoreArr[5][2];
};

scoreMatch ScorePlayerMatch();

scoreMatch ScorePlayerMatch(double pair, double threeKind, double twoPair, double fourKind, double fullHouse, double pairCard, double secPairCard, double threeKindCard, double highC, double lowC)
{
    scoreMatch infunc;
    infunc.scoreArr[0][0] = pair; 
    infunc.scoreArr[0][1] = 2.0*pow(10.0,6.0) + (pairCard * 10000.0) + (highC) + (lowC/100.0);
    infunc.scoreArr[1][0] = threeKind; 
    infunc.scoreArr[1][1] = 4.0*pow(10.0,6.0) + (pairCard * 10000.0) + (highC) + (lowC/100.0);
    infunc.scoreArr[2][0] = twoPair; 
    infunc.scoreArr[2][1] = 3.0*pow(10.0,6.0) + (pairCard* 10000.0) + (secPairCard*100.0) + (highC) + (lowC/100.0);
    infunc.scoreArr[3][0] = fourKind; 
    infunc.scoreArr[3][1] = (8.0*pow(10.0,6.0)) + (pairCard * (1.0 * pow(10.0,4.0))) + (highC) + (lowC/100.0);
    infunc.scoreArr[4][0] = fullHouse; 
    infunc.scoreArr[4][1] = 7.0*pow(10.0,6.0) + (pairCard*10000.0) + (threeKindCard*100.0) + (highC) + (lowC/100.0);
        
    return infunc;
}
 
Last edited:

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Hello, I get this error from code within a header file...any ideas?

ScorePlayerMatch.h:25: error: stray '\20' in program
ScorePlayerMatch.h:25: error: parse error before numeric constant

Well, the compiler tells you.
There's a character in your file that doesn't belong there.
It's not a printable character, that's why the compiler shows it in octal. ("\20").
Find out who to see characters in your source file that are normally invisibile.
Then delete anything that doesn't belong there.
 

Sander

macrumors 6502a
Apr 24, 2008
521
67
The snippet you posted is less than 25 lines, so it's perhaps somewhere else.

One often-occurring cause for having weird characters in your source files is copying it off a web site. Did you type in this code yourself, directly in Xcode?

Also, \20 is ASCII 16, which is a rare control character ("Data Link Escape"). Maybe you ended up feeding UTF8 code to the compiler or something?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.