Joined: 05 Sep 2006 Posts: 378 Location: The pizza country!
Posted: Sun Aug 12, 2007 6:36 am Post subject: [C++]Number of occurrences in a string?
Well i'm coding a parser function, but the number of tokens isn't fixed, so i have to allocate memory before doing it.
Does anyone know a good way of finding number of occurrences without useless functions? (strstr/strchr)
Or i have to go with something like that?
int nTokens = 0;
int bufferlen = strlen(buffer);
for(int i = 0; i < bufferlen; i++)
if(buffer[i] == delimitator)
++nTokens; _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum