C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 9th, 2005, 08:56 AM
MartyConlonJr MartyConlonJr is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 14 MartyConlonJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 10 m 52 sec
Reputation Power: 0
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;
}

Reply With Quote
  #2  
Old February 11th, 2005, 05:25 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
you could use a global variable

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > static int - Is there a limit of 99?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway