Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef UNICODE
- #define UNICODE
- #endif
- #include <iostream>
- #include <Windows.h>
- #include <queue>
- using namespace std;
- void addSomeContent(queue<TCHAR*> &s)
- {
- static int counter=0;
- TCHAR* buffer;
- buffer = new TCHAR[250];
- wsprintf(buffer,TEXT("foo%d"),counter++);
- s.push(buffer);
- if(counter < 100000)
- addSomeContent(s);
- //breakpoint placed here is never reached
- }
- int main (void)
- {
- queue<TCHAR*> strings;
- addSomeContent(strings); //crash point
- while(!strings.empty())
- {
- wcout<<strings.front()<<endl;
- delete [] strings.front();
- strings.pop();
- }
- wcout<<TEXT("Finish!n");
- system("pause");
- return (0);
- }
- #include <iostream>
- #include <queue>
- #include <cstdio>
- using namespace std;
- void addSomeContent(queue<char*> &s)
- {
- static int counter = 0;
- char *buffer = new char[250];
- sprintf(buffer, "foo%d", counter++);
- s.push(buffer);
- if (counter < 100000)
- addSomeContent(s);
- }
- int main(void)
- {
- queue<char*> strings;
- addSomeContent(strings);
- while (!strings.empty())
- {
- cout << strings.front() << endl;
- delete[] strings.front();
- strings.pop();
- }
- cout << "Finish!" << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment