View Single Post
Old 08-09-2003, 07:10 PM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
I am not sure what the goal exactly is so this proggy calculates the amount of characters in a string and counts the occurances of a certain character in a string.

Code:
 #include <string>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, char* argv[])
{
	string str = "hello johnny";

	int i=str.size(); //i=12
	int p = count(str.begin(), str.end(), 'h'); //p=2
	
	return 0;
}
__________________
Valmont is offline   Reply With Quote