Ich versuche, meinen eigenen Cmd in Windows zu machen. Ich brauche eine Alternative zur mir bekannten flstream-Bibliothek. Ich habe von der Iostream-Bibliothek für die Dateieingabe/-ausgabe gehört. Auch wenn es so etwas gibt, können Sie mir ein Beispiel zeigen? Ich bin auch ein Fehler mit diesem Code in Code :: Blocks bekommen:Wie öffne ich eine Datei außerhalb des Arbeitsverzeichnisses in C++ mit <iostream> Bibliothek?
60: Keine Funktion Anpassung für Aufruf von std :: basic_ifstream < char> :: open (std :: __ cx :: string &)
Hier ist mein Code:
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <fstream>
#include <conio.h>
void processor_xH(std::string);
void motherboard_xH(std::string);
void prccept(std::string);
void o_app(std::string);
//Contains global variables and functions
std::string command;
int main()
{
//Check whether the system("") command is availible or exit...
if(system(NULL)) std::cout << "Ok..." << std::endl;
else std::cout << "Sorry, an error occured..." << std::endl;
//Now set the color settings and output directory
system("CLS"); system("COLOR 50");
std::cout << "@jedaiCoder $go-do- ";
//Take command as input string
std::getline(std::cin, command);
processor_xH(command);
//Check for specific commands in string
getchar(); return 0;
}
void processor_xH(std::string input)
{
std::string srchI[]={"prccept", "o-app"};
for(int x=0; x<=1; x++)
{
if((input.find(srchI[x]))!=std::string::npos)
{
//Then find the command
motherboard_xH(srchI[x]);
}
}
}
void motherboard_xH(std::string x)
{
if(x=="prccept") prccept(x);//Command for printing file or text
if(x=="o-app") o_app(x); //Open file for reading writing
}
void prccept(std::string x)
{
}
void o_app(std::string x)//Guys the error is over here
{
std::string y=x.substr(7, 8);
x=x.substr(9, 12);
if(y=="-w" || y=="-r")
{
std::ifstream file;
file.open(x);
}
}
Dieses Projekt könnte auch einige andere Fehler enthalten, so weis bitte sie aus.
Entschuldigen Sie bitte meine Verwendung des Systems ("") Befehl, da ich ein Anfänger bin und ich SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 5|BACKGROUND RED)
kenne, aber ich will Hintergrundfarbe für das ganze Programm einstellen.
bitte Ihr Gehalt der guten Kerl geben, die Ihren Code zu beheben für dich. –
"Bitte lesen Sie meinen Code und beheben Sie ihn" - das, * genau dort * ist der Grund für meine Ablehnung. –
Interessant, das Programm wird fortgesetzt, obwohl ein Fehler aufgetreten ist. IMO, keine gute Sache. –