Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:10:57+00:00 2026-06-02T22:10:57+00:00

I am getting an invalid null pointer error from this section of code. I

  • 0

I am getting an invalid null pointer error from this section of code. I am guessing it is something to do with the strings, but as I have only recently learnt about them, I cannot find the problem.

string batchCipherFiles()
{
int count(0);
string text, file; 
ifstream inputFile;

cout << " How many files do you wish to encrypt?: ";
cin >> count;
for (int i(1) ; i <= count ; ++i)
{
    stringstream ss;
    ss << "unencrypted" << i << ".txt";
    file = ss.str();
    inputFile.open(file.c_str(), ios::in);
    if (inputFile.fail()) 
    {
        cout << "\n An error has occurred.";
    }
    else
    {
        while (!inputFile.eof())
        {
            getline(inputFile, text);
            cout << "\n " << file << " = " << text << "\n\n";
            int applyCeasarShift(string,string);        
            applyCeasarShift(text, file);
        }
        inputFile.close();
    }
}

return (0);
}

Here is the debug line from xstring:

 #ifdef _DEBUG
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line)
{   // report error and die
    if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, message)==1)
    {
        ::_CrtDbgBreak();
    }
}

Thanks in advance for any help.

EDIT: The error occurs on the Return statement, and in the extract from xstring, the yellow arrow is pointing to “::_CrtDbgBreak();”

EDIT 2:

xstring:
basic_string(const _Elem *_Ptr)
    : _Mybase()
    {   // construct from [_Ptr, <null>)
    _Tidy();
    assign(_Ptr);
    }

xutility:
template<class _Ty> inline
void _Debug_pointer(const _Ty *_First, _Dbfile_t _File, _Dbline_t _Line)
{   // test iterator for non-singularity, const pointers
if (_First == 0)
    _DEBUG_ERROR2("invalid null pointer", _File, _Line);
}

stdthrow:
#ifdef _DEBUG
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line)
{   // report error and die
    if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, message)==1)
    {
        ::_CrtDbgBreak();
    }
}

Hopefully this is the right stuff.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:10:58+00:00Added an answer on June 2, 2026 at 10:10 pm

    The problem is that string is the return type for batchCipherFiles but return (0); is being returned: either change the return type or return a string.

    I think the return (0); will be implicitly converted to std::string((char*)0);, causing the crash. The documentation for std::string constructor states:

    Constructs the string with the contents of null-terminated character string pointed to by s. The length of the string is determined by the first null character. s must not be a NULL pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am getting an error: invalid lvalue in assignment. this is the only error
I'm trying to compile some code, but I'm getting an error: Error invalid conversion
I'm getting this error: The remote certificate is invalid according to the validation procedure.
I am getting this error: Data at the root level is invalid. Line 1,
I am getting this error: DataError: (DataError) invalid input syntax for integer: 1.50 CONTEXT:
I'm getting an error (java.io.StreamCorruptedException: invalid type code: 00) when reading in a serialised
Im trying to work with following code i getting this error at xsltProcessor.importStylesheet Error
Im getting this error: ORA-00904: M: invalid identifier --> if I put ('M','F') //single
I'm using JOptionPane.showMessageDialog(null,e,Invalid Name,JOptionPane.ERROR_MESSAGE) method to display the exception extended from Exception class. But
I have been getting an invalid character! on what looks like the £ sign

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.