#my program dont do the function i want
64 messages ยท Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
@gusty belfry
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
#include <iostream>
#include <fstream>
#include <sstream>
#include <Windows.h>
#include <string>
#include <thread>
#include <chrono>
using namespace std;
string unsernamec;
string passwordc;
string content;
void erstelltdatei() {
ifstream checkfile;
checkfile.open("data.txt");
if (checkfile)
{
cout << "r";
// cout << "Checking details...\n";
//Sleep(300);
/*using namespace std::chrono_literals;
std::this_thread::sleep_for(2000ms);
*/
}
else {
cout << "file missing!\n" << endl;
cout << "creating file...\n";
std::ofstream data("data.txt"); // erstellt datei txt daten usw.
Sleep(3000);
data << "username:\n" << std::endl;
data << "password:\n" << std::endl;
cout << "insert inputs...\n";
Sleep(3000);
data.open("data.txt"); Sleep(5000);
data.close();
cout << "file created successfully!\n";
cout << "restart program!";
Beep(440, 400);
Sleep(7000);
exit;
}
}
void liesaus() {
std::ifstream data("data.txt");
std::string line;
int desired_line_number = 2; // change to the line number you want
int current_line_number = 1;
string content;
while (getline(data, line)) {
if (current_line_number == desired_line_number) {
std::cout << "Line " << desired_line_number << ": " << line << std::endl;
line = content;
break;
}
current_line_number++;
}
data.close();
cout << content;
}
this the code of the functions
when i use the the local windows debugger everything working
but when i build the program it skip this functions
if (checkfile.good())
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.
not working
i tried this but its the same
@whole lotus
@sudden folio
can you help me
im not in windows so i cant just plug in your code and try compiling
hey bro. I can give it a shot. Gimme 2 min
so whats the issue? that the txt file doesnt get the inputs?
since it works fine if i run the exe when ive compiled it
@gusty belfry
it work when i use the debug mode
but i build the program its not working bro idk why
it works for me. can u define "Not working"?
its open the console i input the informations its close instantly
yes
but when i debug its working
since the application exits
yes, since visual studio keeps the window opened regardless
try adding getline() on the end of main
getchar()*
sry, try adding sleep()
ahhhh
When you run an exe it will run the code and then close the consol window by default
๐
alright thanks
can i ask you how did learnd c++
but not in this case
when it crashes in visual studio, you get a reason, but not when running a raw exe
i understand now
I learned c++ in university. I can send you some links to get more confortable with the basics if you want?
yes that would be nice
ait, gimme some minutes and ill find some nice stuff ๐
Here is a very good website for all the basics. They have exercises aswell.
This C++ tutorial for beginners shows you how to get started with C++ quickly. Learn C++ basics in 1 hour and get ready to learn more!
- Subscribe for more C++ tutorials: https://goo.gl/6PYaGF
- Want to learn more? Try my Complete C++ Programming course: https://bit.ly/ultimate-cpp
- Get my free C++ cheat sheet and summary notes: https://bit.ly...
This youtuber is decent, I think i've watched his python intro which was pretty good.
@gusty belfry But I would recommend reading a bit on w3schools and doing some execises and then go watch his video and take notes ๐
Thank you and let us know if you have any more questions!
Thank you ๐ Just ask any questions you want ๐
Good luck aswell!