Re: basic function tell an function
| Newsgroups | gmane.linux.debian.user |
|---|---|
| Message-ID | <ao/[email protected]> |
On Wed, Aug 26, 2026 at 07:15:00PM +0000, Jean-Christophe wrote:
> hello,
>
> i try to write an my_files.txt
>
> and see the output on tty
As Dan Ritter said in this thread: you are calling fonction_deux:
> bool fonction_deux (){
> fstream my_file;
> my_file.open("my_file.txt", ios::out);
> if (!my_file) {
> cout << "File not created!";
...and here, you are writing to stdout (what you call "tt", I think)
> }
> else {
> cout << "File created successfully!\n" << endl;
> cout << fonction_un() << endl;
>
> my_file.close();
> }
> var_fonction_deux = true;
> return var_fonction_deux;
> }
and in all the other places too ("cout" writes to stdout).
If you want to write to your fstream my_file, which is
connected to "my_file.txt") you have to do something like
my_file << "some text going to file" << endl;
(See https://www.w3schools.com/cpp/ref_fstream_fstream.asp for a more
complete example).
Cheers
--
t
signature.asc
(application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCao/JgAAKCRAFyCz1etHa RoMvAJ4jDUHipfoFGt0UkAzDBO0kZfxW1ACfYHoOJbdwzu6X/MXAeia8eUJCdfk= =lsLq -----END PGP SIGNATURE-----