【发布时间】:2016-01-28 07:56:49
【问题描述】:
所以这是我的问题...当我尝试在 Visual Studio 中写入 .txt 文件时遇到此错误。在命令提示符下,它给了我这个错误: “c:\users\carter\documents\visual studio 2015\Projects\JournalEntry\Debug\JournalEntry.exe”不是内部或外部命令、可运行程序或批处理文件。
这是我在 Visual Studio 中遇到的错误: 错误 C2679 二进制“>>”:未找到采用“const char [24]”类型右侧操作数的运算符(或没有可接受的转换),第 18 行。
我的程序名称是 JournalEntry.cpp,我要做的只是写入一个名为 Journal.txt 的文件
这是我的代码:
// JournalEntry.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
fstream myJournal;
myJournal.open("Journal.txt");
if (myJournal.is_open())
{
myJournal >> "This is my first line! ";
myJournal.close();
}
else
{
cerr << "Error opening file ";
exit(1);
}
return 0;
}
【问题讨论】:
标签: c++ visual-c++