1

I was having errors with a project that I created using the console application template and decide to re-create the project with an empty template. This seems to have dealt with the "unresolved external symbol" error I was receiving but now the console won't open when I call cout for output.

#include<iostream>
#include<string>
#include <fstream>
#include <vector>
#include "pch.h"
#include "word.h"
#include "dictionary.h"

using namespace std;

int main()
{
    Dictionary dic;
    dic.loadDictionary();
    cout >> "Hey\n" >> endl;
    cout.flush();
}

There are two class files that are being used but as there are no error I don;t believe they are needed to be seen.

Thanks for any help!

EDIT: The original project that was receiving errors were "LNK2019 unresolved external symbol "public: void __thiscall Dictionary::loadDictionary(void)" (?loadDictionary@Dictionary@@QAEXXZ) referenced in function _main ConsoleApplicationASS"

  • Can you post the exact errors you get? – P.W Apr 15 '19 at 06:44
  • @P.W Well I just realised that it seems there is something major wrong with the project or Im not doing something right, because I'm not receiving any errors whatsoever, even if I intentionally mess up the syntax – Vehicular IT Apr 15 '19 at 06:52

2 Answers2

1

Use << instead of >>. Also put getch() at the end for the console to wait for your input so that you can see the console output.

After edit on the question, you should read about solving the LNK2019.

Shridhar R Kulkarni
  • 6,653
  • 3
  • 37
  • 57
  • No luck, when I rebuild it still doesn't appear with the console. However, Im unsure how I was not getting errors when using the wrong << with cout. – Vehicular IT Apr 15 '19 at 05:38
  • Try a sample hello world first to clear your doubts. https://www.programiz.com/cpp-programming/examples/print-sentence – Shridhar R Kulkarni Apr 15 '19 at 05:42
  • The issue isn't that I can't write a program that can output to console, my issue is that I have the code that would typically output to a console that would open up when the project is built. But my project is simply not doing that even though it should. – Vehicular IT Apr 15 '19 at 05:46
  • Then to solve this issue one needs to have a look at the project. By just having a look at the code you pasted in your question we cannot figure out the bug. Please give us a mcve. https://stackoverflow.com/help/mcve – Shridhar R Kulkarni Apr 15 '19 at 05:50
  • Well there are no errors, so should I post the full source code? – Vehicular IT Apr 15 '19 at 06:05
  • If the full source code is small enough you can post. But then it becomes like 'Can someone please debug this for me?'. So good to learn usage of debugging tools. MCVE https://stackoverflow.com/help/mcve is always recommended. – Shridhar R Kulkarni Apr 15 '19 at 06:10
  • Yea I get that, should I just re-post the question and rephrase it as an issue with the project instead? – Vehicular IT Apr 15 '19 at 06:12
  • If it is project issue, the question might go broad or possibly drift away from the original question. Being a new contributor on the site, I recommend reading https://meta.stackexchange.com/questions/43478/exit-strategies-for-chameleon-questions. I recommend leaving this question as is. Ask a new question if you can come up with MCVE. Something similar to your doubt is https://meta.stackexchange.com/questions/296738/should-i-re-ask-a-question-if-i-have-edited-it-beyond-recognition. – Shridhar R Kulkarni Apr 15 '19 at 06:29
0

Maybe it is showing up, and closing before you see any output. Try Ctrl+F5. That makes you input a keystroke at the end of execution similar to the getch() command.

CAPSLOCK
  • 6,243
  • 3
  • 33
  • 56
Roy2511
  • 938
  • 1
  • 5
  • 22