I must write a program that tells the user how many characters are in the string that they entered. But my pointer is giving me an error, telling me that it is equal to nullptr.
Here is my code:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int countChars(int*);
int *strPtr = nullptr;
string word;
int main()
{
countChars(strPtr);
cout << "That string has " << *strPtr << " characters in it.";
cin.get();
}
int countChars(int *strPtr)
{
string word;
cout << "Enter a string: ";
cin >> word;