• Oh d-ai-ry d-ai-ry me

    From Richard Heathfield@3:633/280.2 to All on Sat May 31 06:01:50 2025
    This evening I accidentally bumped into a chatbot, and I wondered
    whether it was any good at C programming.

    I was impressed when it solved Goldbach's Conjecture (admittedly
    for small n) and 5-disc Hanoi, but then I thought back to a
    recent thread here (which I have no intent of resurrecting), so I
    asked it if it could have saved me a job if I'd only asked it a
    few hours ago.

    Judge for yourselves!

    I asked: "Write a program that is valid C90 but invalid C99."

    ChatGPT said:

    Certainly! To illustrate this, I'll write a C program that is
    valid in C90 but invalid in C99. The key difference between C90
    and C99 revolves around variable declaration and initialization.
    Key Issue:

    In C90, variables can only be declared at the beginning of a
    block (before any executable code).

    In C99, variables can be declared anywhere within a block,
    even between statements.

    C Program Example:

    This program is valid in C90 but invalid in C99 because the
    variable x is declared after executable code.

    #include <stdio.h>

    int main() {
    printf("Hello, world!\n");

    int x = 5; // Declaration after executable code (invalid in
    C99)

    printf("x = %d\n", x);
    return 0;
    }

    Why it’s Valid in C90:

    In C90, all variable declarations must appear at the
    beginning of a block (before any code). This program would be
    valid in C90 because x is declared after the printf statement,
    but only the declaration of x itself breaks the rule in C99.

    Why it’s Invalid in C99:

    In C99, variables can be declared anywhere within a block,
    even after executable statements (not just at the beginning of a
    block). This is why the above code would cause an error in C99,
    as the variable x is declared after a statement (printf).

    Compilation Example:

    If you compile this program with a C99 compiler (e.g., GCC),
    you'll get an error similar to this:

    error: variable 'x' declared after statement

    To summarize:

    C90 allows this style (declaration after code).

    C99 does not allow it, so the program becomes invalid.


    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: Fix this later (3:633/280.2@fidonet)
  • From Ar Rakin@3:633/280.2 to All on Wed Jun 4 02:06:50 2025
    On 5/31/25 2:01 AM, Richard Heathfield wrote:
    This evening I accidentally bumped into a chatbot, and I wondered
    whether it was any good at C programming.

    I was impressed when it solved Goldbach's Conjecture (admittedly for
    small n) and 5-disc Hanoi, but then I thought back to a recent thread
    here (which I have no intent of resurrecting), so I asked it if it could have saved me a job if I'd only asked it a few hours ago.

    Judge for yourselves!

    I asked: "Write a program that is valid C90 but invalid C99."

    ChatGPT said:

    Certainly! To illustrate this, I'll write a C program that is valid in
    C90 but invalid in C99. The key difference between C90 and C99 revolves around variable declaration and initialization.
    Key Issue:

    ÿÿÿ In C90, variables can only be declared at the beginning of a block (before any executable code).

    ÿÿÿ In C99, variables can be declared anywhere within a block, even
    between statements.

    C Program Example:

    This program is valid in C90 but invalid in C99 because the variable x
    is declared after executable code.

    #include <stdio.h>

    int main() {
    ÿÿÿ printf("Hello, world!\n");

    ÿÿÿ int x = 5;ÿ // Declaration after executable code (invalid in C99)

    ÿÿÿ printf("x = %d\n", x);
    ÿÿÿ return 0;
    }

    Why it’s Valid in C90:

    ÿÿÿ In C90, all variable declarations must appear at the beginning of a block (before any code). This program would be valid in C90 because x is declared after the printf statement, but only the declaration of x
    itself breaks the rule in C99.

    Why it’s Invalid in C99:

    ÿÿÿ In C99, variables can be declared anywhere within a block, even
    after executable statements (not just at the beginning of a block). This
    is why the above code would cause an error in C99, as the variable x is declared after a statement (printf).

    Compilation Example:

    If you compile this program with a C99 compiler (e.g., GCC), you'll get
    an error similar to this:

    error: variable 'x' declared after statement

    To summarize:

    ÿÿÿ C90 allows this style (declaration after code).

    ÿÿÿ C99 does not allow it, so the program becomes invalid.


    This is the reason why I tell people who write code that AI/LLMs can't
    ever replace them like this. AI tools can only be a tool that you use.
    To write code, you'd still need to know something by yourself at the end
    of the day.

    --
    Rakin

    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: OSN (3:633/280.2@fidonet)
  • From Anton Shepelev@3:633/280.2 to All on Mon Jun 9 21:21:55 2025
    Richard Heathfield:

    I asked: "Write a program that is valid C90 but invalid
    C99."

    ChatGPT said:

    Certainly! To illustrate this, I'll write a C program that
    is valid in C90 but invalid in C99.

    This AI cannot speak English and answer questions as they
    are asked:

    1. You did not ask it /whether/ it were possible to write
    such a program, so its answer "Certainly" either makes
    no sense, or means agreement to fullfil your request.

    2. If it means agreement, the following sentence makes no
    sense, for what is it going to illustrate (if not the
    possiblity of such a program)?

    3. And then it cocludes with a blatant tautology,
    promising to "illustrate" the wrting of a C90-but-not-
    C99 program, by writing a C90-but-not-C99 program.

    Its diction is like that of schoolchild taught to start an
    answers by repeating the question, but not understanding how
    to do it.

    --
    () ascii ribbon campaign -- against html e-mail
    /\ www.asciiribbon.org -- against proprietary attachments

    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)
  • From Roberto@3:633/280.2 to All on Mon Jun 9 23:13:31 2025
    After serious thinking Anton Shepelev wrote :
    Richard Heathfield:

    I asked: "Write a program that is valid C90 but invalid
    C99."

    ChatGPT said:

    Certainly! To illustrate this, I'll write a C program that
    is valid in C90 but invalid in C99.

    This AI cannot speak English and answer questions as they
    are asked:

    1. You did not ask it /whether/ it were possible to write
    such a program, so its answer "Certainly" either makes
    no sense, or means agreement to fullfil your request.

    2. If it means agreement, the following sentence makes no
    sense, for what is it going to illustrate (if not the
    possiblity of such a program)?

    3. And then it cocludes with a blatant tautology,
    promising to "illustrate" the wrting of a C90-but-not-
    C99 program, by writing a C90-but-not-C99 program.

    Its diction is like that of schoolchild taught to start an
    answers by repeating the question, but not understanding how
    to do it.

    + 1

    Thanks to underlining it.

    --
    Roberto

    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)
  • From Roberto@3:633/280.2 to All on Mon Jun 9 23:17:17 2025
    Roberto submitted this idea :
    After serious thinking Anton Shepelev wrote :
    Richard Heathfield:

    I asked: "Write a program that is valid C90 but invalid
    C99."

    ChatGPT said:

    Certainly! To illustrate this, I'll write a C program that
    is valid in C90 but invalid in C99.

    This AI cannot speak English and answer questions as they
    are asked:

    1. You did not ask it /whether/ it were possible to write
    such a program, so its answer "Certainly" either makes
    no sense, or means agreement to fullfil your request.

    2. If it means agreement, the following sentence makes no
    sense, for what is it going to illustrate (if not the
    possiblity of such a program)?

    3. And then it cocludes with a blatant tautology,
    promising to "illustrate" the wrting of a C90-but-not-
    C99 program, by writing a C90-but-not-C99 program.

    Its diction is like that of schoolchild taught to start an
    answers by repeating the question, but not understanding how
    to do it.

    + 1

    Thanks to underlining it.

    Thanks _for_ underlining it.

    --
    Roberto

    --- MBSE BBS v1.1.1 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)