tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] issue found in "tcc 0.9.24"


From: G. Belllini
Subject: [Tinycc-devel] issue found in "tcc 0.9.24"
Date: Thu, 29 May 2008 10:09:58 +0000 (GMT)



Hi guys,

I fell into a problem in using "tcc 0.9.24" if you are interested.

Here is a code showing the error :
You should notice that variable "i" is not incremented. It looks like variable "i" is resetted
just after the "scanf" instruction.

#include <stdio.h>

main ()
{
  char   i; // used as number that we want on 1 byte only
  char   tmp_str[2];  // this is a string

  i = 0;

  do
  {

    printf ("\n");
    printf ("Type 2 characters : ");
    scanf  ("%s", &tmp_str);

    printf("\n");
    printf("You typed %s\n", tmp_str);

    i++;
    printf("DEBUG : i = %d\n", i);

  } while (i < 5);

}


Ok, now a workaround is to declare variable "tmp_str" as first. Like this :

#include <stdio.h>

main ()
{
  char   tmp_str[2];  // this is a string
  char   i; // used as number that we want on 1 byte only

  i = 0;

  do
  {

    printf ("\n");
    printf ("Type 2 characters : ");
    scanf  ("%s", &tmp_str);

    printf("\n");
    printf("You typed %s\n", tmp_str);

    i++;
    printf("DEBUG : i = %d\n", i);

  } while (i < 5);

}



__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités
http://mail.yahoo.fr Yahoo! Mail
reply via email to

[Prev in Thread] Current Thread [Next in Thread]