Hello,
I am getting two instances of the warning C4267 in my function. This warning says: 'initializing' : conversion from 'size_t' to 'int', possible loss of data
I looked this up on the internet and it doesn't seem to be a great big deal, but I was wondering if there was a method I could use to rewrite the function so I can get a clean compile.
I am sorry about the indentation/spacing. It looks alot better in Visual Studio.Code:// This program will count the occurrences of a string within a string. #include <iostream> // cin, cout, <<, >> #include <string> // string using namespace std; int count; int occurCount(string quote) { cout << quote << endl; // quote will come from a driver file int position = quote.find ("a spider", 0); // warning C4267 if (position == string::npos) count = 0; else count = 1; while (position != string::npos) { position = quote.find ("a spider", position + 1); //C4267 if (position > 0) { count++; } } return count; }