Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Jul 2020 17:04:26 +0530
From:      rahul deshmukh <rahul.dshmkh1@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   strange output in c program
Message-ID:  <CAFa7P3fnvqCWfPJU-moJEyx0Wx=bL0sRjhMKLkyiBvN9k6ReSg@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi Team,
i was learning c programming and came across a very strange output. kindly
someone please guide me if i am missing anything.

rdx@FreeBSD:~/Projects/Clang/chapter3 % uname -a
FreeBSD FreeBSD 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64
========================================================================
rdx@FreeBSD:~/Projects/Clang/chapter3 % cat example6.c
#include <stdio.h>
int main()
{
    int a = 300, b, c;
    if(a >= 400)
    {
        printf("shouldn't print\n");
        b = 300;
    }
    c=200;
    printf("%d %d\n", b, c);
    return 0;
}
=========================================================
rdx@FreeBSD:~/Projects/Clang/chapter3 % make example6
`example6' is up to date.
rdx@FreeBSD:~/Projects/Clang/chapter3 % ./example6
300 200==> should be garbage value instead of 300?



-- 
Thank you
---------------------
Rahul Deshmukh



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFa7P3fnvqCWfPJU-moJEyx0Wx=bL0sRjhMKLkyiBvN9k6ReSg>