-2
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string message;
    cout << "Type your message: ";
    cin.ignore();
    getline(cin, message);

    return 0;
}

It gives getline function is not defined error.

I just want to hold the writed string inside the message veriable.

Here's the picture

  • inculated == included ? – Barmar Jul 14 '17 at 16:11
  • 1
    Error c3861 means you used an undeclared variable or function. So you must not have the correct `#include` lines. Post your whole program. – Barmar Jul 14 '17 at 16:13
  • 2
    Don't summarize; show real code. And show all of the error message. – Pete Becker Jul 14 '17 at 16:13
  • This question will most likely be answerable if you show the real example including actual error message instead of describing your code and error. – drescherjm Jul 14 '17 at 16:14
  • @PeteBecker it's all of the code – Sefa Kalkan Jul 14 '17 at 16:16
  • No it is not the code. Where is the integer variable in the code presented? Also the error does not make sense for the code presented and you don't have the includes. – drescherjm Jul 14 '17 at 16:19
  • @SefaKalkan -- no, it's not all of the code. Unless the code has no `#include` directives. Your goal in writing a question should be to make it as easy as possible for readers to copy the code and run it through their own compiler. – Pete Becker Jul 14 '17 at 16:19
  • @PeteBecker it's here https://i.hizliresim.com/VMDL8y.png – Sefa Kalkan Jul 14 '17 at 16:30
  • ***it's here*** That was not legal code. You were describing code instead of adding the text of your code to your question. I do now see that at some point you added a picture of your screen however pictures of text are generally not good for StackOverflow. Remember at StackOverflow your question with answer is intended to help readers in the future with the same issue. How long will the picture exist on the external site? Also how does one search the text from google when it is in a picture to even find this question? – drescherjm Jul 14 '17 at 16:50
  • @drescherjm the code on the pitcure same with the code which one on the webside and this exist webside have google security i cant added the code on the comments and i did something like that. – Sefa Kalkan Jul 14 '17 at 17:07
  • Its now fixed by @ZDF. But was not at the time that we posted the comments. That was the point of us asking for clarification. This is also why your question got closed and has a negative rating. – drescherjm Jul 14 '17 at 17:13
  • yeah i know but this site does'nt count #include's as a code and it does'nt adding that #include thinks in code so i added it on top of the code what should i can do more if it's giving me error? – Sefa Kalkan Jul 14 '17 at 17:40
  • Use the {} option when entering code next time you ask a question. It should not complain about # if you do that. – drescherjm Jul 14 '17 at 18:11

1 Answers1

1

"...string, stdafx.h and iostream...": "stdafx.h" must be the first line. The compiler will ignore everything above it (<string> will not be included, so the compiler will complain: getline not found).

I do not know what you're trying to do but the code below will compile and run:

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
  string message;
  cout << "Type your message: ";
  cin.ignore();
  getline( cin, message );

  return 0;
}
zdf
  • 4,382
  • 3
  • 18
  • 29