#my program dont do the function i want

64 messages ยท Page 1 of 1 (latest)

gusty belfry
bright crowBOT
#

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

Screenshots!

Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!

gusty belfry
#
#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

quaint timber
#

if (checkfile.good())

bright crowBOT
#

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.

gusty belfry
#

not working

gusty belfry
#

@whole lotus

#

@sudden folio

#

can you help me

sudden folio
#

im not in windows so i cant just plug in your code and try compiling

whole lotus
#

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

gusty belfry
#

it work when i use the debug mode

#

but i build the program its not working bro idk why

whole lotus
#

it works for me. can u define "Not working"?

gusty belfry
#

its open the console i input the informations its close instantly

whole lotus
#

yes

gusty belfry
#

but when i debug its working

whole lotus
#

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()

gusty belfry
#

here ?

whole lotus
#

yes, add sleep

#

Sleep(3000)

#

you will see that it will exit after 3 sec

gusty belfry
#

ahhhh

whole lotus
#

When you run an exe it will run the code and then close the consol window by default

#

๐Ÿ˜›

gusty belfry
#

i understand

#

bruhhh im so dumb

#

thank you bro

whole lotus
#

nahhh

#

but keep in mind

gusty belfry
#

alright thanks

whole lotus
#

the reason it can sometimes close when running the exe

#

is also because it crashes

gusty belfry
#

can i ask you how did learnd c++

whole lotus
#

but not in this case

#

when it crashes in visual studio, you get a reason, but not when running a raw exe

whole lotus
gusty belfry
#

yes that would be nice

whole lotus
#

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 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 ๐Ÿ™‚

gusty belfry
#

alright thank you i takes that as notice

#

you are the best

#

!solved

bright crowBOT
#

Thank you and let us know if you have any more questions!

whole lotus
#

Good luck aswell!