Re: basic function tell an function
Jean-Christophe <[email protected]>
| Newsgroups | gmane.linux.debian.user |
|---|---|
| Message-ID | <4d36407a7de2286ba532942597bb240f22bde834.camel@blues-softwares.net> |
If you have any advice for benchmarks and other performance tests.
just to see how the code behaves with several call functions
On Thu, 2026-08-27 at 23:57 +0000, Jean-Christophe wrote:
> I'm just exhausted,
> I passed it in an LLM, you can see beginner's mistakes.
>
> The code works,
>
> I would like to discuss the methodology to replace variables under
> vim
>
> :s/something
>
> it's my only error there is surely a way to proceed, I don't know I
> tried to do something and when I knew that I was reaching the goal
> the
> LLM saw what I did not see. Probably a misuse of VIM, like a TXT, and
> not an IDE
>
> --- original_code.cpp
> +++ corrected_code.cpp
> @@ -1,3 +1,4 @@
> +#include <string> // Added: Required for std::string usage
> #include <iostream>
> #include <fstream>
> using namespace std;
> @@ -10,13 +11,13 @@
> int bd=100;
> string file="";
> string file_write="";
>
> -char * fonction_un() { // Error: Incompatible return type (char* vs
> std::string)
> +string fonction_un() { // Fixed: Return type changed to std::string
> cout << "chocolat" << endl;
> - cout << "chocolat " << age << "ans" << endl; // Missing
> space
> before "ans"
> + cout << "chocolat " << age << " ans" << endl; // Fixed:
> Added
> space for readability
> cout << "chocolat a environ " << bd << " bandes-dessinées."
> <<
> endl;
>
> - file += "chocolat" + endl; // Error: 'endl' is a stream
> manipulator, not a string
> - file += "chocolat" + age + "ans" + endl; // Error: Cannot
> concatenate int with string directly
> + file += "chocolat\n"; // Fixed: Replaced 'endl' with
> newline
> character
> + file += "chocolat " + to_string(age) + " ans\n"; // Fixed:
> Used to_string() to convert int to string
>
>
> //var_fonction_un = true;
> @@ -24,14 +25,14 @@
>
> void fonction_deux (){
> - fstream my_file; // Note: fstream is overkill for write-
> only
> operations
> + ofstream my_file; // Fixed: ofstream is more appropriate
> for
> write-only
> my_file.open("my_file.txt", ios::out);
> - if (!myfile) { // Error: Variable name typo (myfile vs
> my_file)
> + if (!my_file) { // Fixed: Corrected variable name to match
> declaration
> cout << "File not created!";
> }
> else {
> cout << "File created successfully!\n" << endl;
> - myfile << fonction_un() << endl; // Error: Variable
> name typo (myfile vs my_file)
> + my_file << fonction_un() << endl; // Fixed:
> Corrected
> variable name
>
> - myfile.close(); // Error: Variable name typo
> (myfile
> vs my_file)
> + my_file.close(); // Fixed: Corrected variable name
> }
> //var_fonction_deux = true;
> //return file_write;
>
>
> On Thu, 2026-08-27 at 20:17 +0000, Jean-Christophe wrote:
> > i was think learn code with LLM, the result is that just now way,
> > just
> > a zero logicial, zero methode and zero undestand on what i do
> >
> > i just try without LLM after...
> >
> > On Thu, 2026-08-27 at 20:13 +0000, Jean-Christophe wrote:
> > > hi bro,
> > >
> > > there is my fantastic code don't work, after lot of time to vibe
> > > code
> > >
> > > i just a stupid man,
> > >
> > > i have no idea about what I do and why it doesn't work
> > >
> > > cheers
> > > --
> > > #include <iostream>
> > > #include <fstream>
> > > using namespace std;
> > >
> > > bool var_fonction_un = false;
> > > bool var_fonction_deux = false;
> > >
> > > int age=25;
> > > int bd=100;
> > > char file;
> > > char file_write;
> > >
> > > string file = "";
> > > string file_write = "";
> > >
> > > string fonction_un() {
> > > cout << "chocolat" << endl;;
> > > cout << "chocolat " << age << "ans" << endl;
> > > cout << "chocolat a environ " << bd << " bandes-
> > > dessinées."
> > > <<
> > > endl;
> > >
> > > file += "chocolat" + endl;
> > > file += "chocolat" + age + "ans" + endl;
> > > file += "chocolat a environ " + bd + " bandes
> > > dessinées."
> > > +
> > > endl;
> > >
> > > //var_fonction_un = true;
> > > return file;
> > > }
> > >
> > > void fonction_deux (){
> > > fstream my_file;
> > > my_file.open("my_file.txt", ios::out);
> > > if (!MyFile) {
> > > cout << "File not created!";
> > > }
> > > else {
> > > cout << "File created successfully!\n" << endl;
> > > MyFile << fonction_un() << endl;
> > > MyFile << fonction_un() << endl;
> > > MyFile << fonction_un() << endl;
> > > MyFile << fonction_un() << endl;
> > > MyFile << fonction_un() << endl;
> > >
> > >
> > >
> > >
> > > MyFile.close();
> > > }
> > > //var_fonction_deux = true;
> > > return file_write;
> > > }
> > >
> > > int main() {
> > > fonction_deux();
> > >
> > > return 0 ;
> > > }
> > >
> > >
> > >
> > > On Wed, 2026-08-26 at 19:15 +0000, Jean-Christophe wrote:
> > > > hello,
> > > >
> > > > i try to write an my_files.txt
> > > >
> > > > and see the output on tty
> > > >
> > > > i see on tty, but no write my_files.txt
> > > >
> > > >
> > > > #include <iostream>
> > > > #include <fstream>
> > > > using namespace std;
> > > >
> > > > bool var_fonction_un = false;
> > > > bool var_fonction_deux = false;
> > > >
> > > > int age=25;
> > > > int bd=100;
> > > >
> > > >
> > > > bool fonction_un() {
> > > > cout << "chocolat" << endl;;
> > > > cout << "chocolat " << age << "ans" << endl;
> > > > cout << "chocolat a environ " << bd << " bandes-
> > > > dessinées."
> > > > <<
> > > > endl;
> > > >
> > > > var_fonction_un = true;
> > > > return var_fonction_un;
> > > > }
> > > >
> > > > bool fonction_deux (){
> > > > fstream my_file;
> > > > my_file.open("my_file.txt", ios::out);
> > > > if (!my_file) {
> > > > cout << "File not created!";
> > > > }
> > > > else {
> > > > cout << "File created successfully!\n" <<
> > > > endl;
> > > > cout << fonction_un() << endl;
> > > >
> > > > my_file.close();
> > > > }
> > > > var_fonction_deux = true;
> > > > return var_fonction_deux;
> > > > }
> > > >
> > > > int main() {
> > > > fonction_deux();
> > > >
> > > > return 0 ;
> > > > }
> > > >
> > > > --
> > > >
> > > > https://bpa.st/3PM5U <-- work
> > > >
> > > > Anyone know why my program doesn't write my_file.txt?
> > > >