| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
static int - Is there a limit of 99?
I am running a program I have created that calls a function to update the database each time an action is made. It has a static int set so that each time it calls the function it increments by one. I was checking that the database wasn't full, that it was still calling this function and the like, but it always seemed to stop on 98 calls. I did some tracing and found that the static int stays at 99 after incrementing from 0. Is this weird behaviour or the way it is supposed to be, and if so, does anyone know a way to set a static variable that can increment as much as needed?
Here is the function: int updatePlayByPlay(int gameID, int quarterNumber, char *description) { static int playNum = 0; cout << playNum; char myQuery[400]; pConnection = mysql_init(NULL); if(!pConnection) return 0; if(mysql_real_connect(----MYSQL DATABASE PARAMETERS EDITED----- == NULL) return 0; sprintf(myQuery, "INSERT INTO playbyplay(Game_ID, Play_ID, Quarter, HomeScore, AwayScore, Description) VALUES(%d,%d,%d,%d,%d,'%s')", gameID, playNum, quarterNumber, homeTeam->pts, awayTeam->pts, description); if(mysql_query(pConnection,myQuery) != 0) //execute the query { printf("Error Executing the query: %s\n\n",mysql_error(pConnection)); } playNum++; return 0; } |
|
#2
|
|||
|
|||
|
you could use a global variable
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > static int - Is there a limit of 99? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|