查找Status_Stack_Buffer_Overrun的来源

时间:2016-03-28 17:49:24

标签: c++ memory buffer

在我的程序中我在while循环中使用switch语句来生成用户菜单。运行我的前两个选项时,我编码工作正常,然后带我回到用户菜单。但是当输入'9'时,退出选项我遇到一个断点并收到一条消息,说明遇到了Status_Buffer_Overrun。对内存分配的工作方式不太了解我对导致这个问题的原因感到有些困惑。

这是我的main.cpp文件的代码。

#include<string>
#include<iostream>
#include "twitcurl.h"
#include "curl/curl.h"
#include"classes.h"

FILE _iob[] = { *stdin, *stdout, *stderr };

extern "C" FILE * __cdecl __iob_func(void)
{
    return _iob;
}


void oauthLogin(twitCurl &twitterObj);
bool login(twitCurl&);


int main(int argc, char *argv[])
{
    //make twitcurl instance
    twitCurl twitterObj;

    bool load = true;
    oauthLogin(twitterObj);
    load = login(twitterObj);
    if (load == false)
    {std::cout << "error." << std::endl; }
    else
    {
        user currentUser;
        currentUser.loadUserData(twitterObj);
        char menuChoice;
        //user is now logged in. Give them menus screen.
        do
        {

            std::cout << "1 - View your timeline.\n";
            std::cout << "2 - Send tweet.\n";
            std::cout << "3 - See Recommended Hashtags.\n";
            std::cout << "4 - See Degrees of separation.\n";
            std::cout << "9 - Exit. \n";
            std::cout << "Enter your choice and press return: "; std::cin >> menuChoice;

        } while (menuChoice != '9');
            switch (menuChoice)
            {
            case '1':

                currentUser.loadTimeline(twitterObj);
                break;

            case '2':

                currentUser.sendTweet(twitterObj);
                break;
            case'9':

                break;

            default:

                std::cout << "Pick a valid choice.\n" << std::endl;
                std::cout << "Please enter a valid choice." << std::endl;

                break;

               }
              }
return 0;
};

0 个答案:

没有答案