Wednesday, 12 December 2007

unset system attribute changed by virus

Some kind of viruses turn your data files and folders into system objects so that it cannot be read, modified or deleted.
This cannot be undone in Windows simply by uncheck the properties READ-ONLY and HIDDEN. In fact, as a file is treated as a system file, the attribute HIDDEN is even disabled to keep the computer safe.
So, DOS (or command prompt) can solve this problem. The command to type is:


attrib -s -h -r [path\]

Hey, so that's what is called "command-line power". Hehehe...

---------- UPDATED May 17th 2009 -----------
The command line seemed laborious since I had NexusFile installed on my machine. All I need to do is click and delete. No fake system file can get through the this file explorer.
Worth to try, that's just part of the cookies.

^_^

Tuesday, 11 December 2007

fflush

scanf issue in Eclipse IDE

#include
void main(){
     float a,b;
     double tich;
     printf("%s","Nhap so thu nhat: ");
     fflush(stdout); //tai sao co them dong nay moi printf truoc?
     scanf("%f",&a);
     printf("%s","Nhap so thu hai: ");
     fflush(stdout); //
     scanf("%f",&b);
     tich = a * b;
     printf("Tich 2 so la: %f",tich);
}

Steffen
I believe that the '\n' character with C functions (e.g. printf()) works  similarly to C++'s endl (i.e. '\n' will implicitly flush the buffer for> you). C++ gives you a bit more control as you are able to insert new lines without flushing the buffer (if desired).
In your test case, I see output before the scanf()'s when running this directly from the command line. However, I know better than to try that from within Eclipse due to the mentioned bug in one of my previous posts.
I suggest you try running your program directly from the command line (either in a command window if you're using Windows, or a terminal window on *nix/Mac) and see if the output differs from when you run it within Eclipse. If your results are consistent then I must have missed something, otherwise I suggest you get involved the bug that I mentioned as I have a feeling that it effects a lot of people (and is quite annoying, to say the least). If I'm running my program on my Windows console, the output appears as intended. But I don't think that it has something to do with the bug you've found since the flushing doesn't take place in Eclipse 3.1 RC1 and Eclipse 3.1 final release.

DaCypher:
First of all, "endl" flushes the output buffer as well as inserting a newline. Doing an explicit flush should have no effect. Are you sure about this? I'm only familiar with the C case, where a n in a printf() statement flushes the output buffer *if the output is going to a terminal*. If the output is going to a file, n does not flush the buffer. I have to ask about this. The following program will never show ANY output, before entering values for scanf, if I don't explicitly flush thestdout.

#include
int x;
double pi;
char c;
char d;
char str[20];
int main(){
     x = 5;
     pi = 3.1415926535897932;
     c = 255;
    d = 'a';
     printf("%fn", pi);
     printf("%dn", c);
     printf("%cn", d);
     printf("Enter number: ");
//fflush(stdout);
     scanf("%d", &x);
     printf("Enter string: ");
//fflush(stdout);
     scanf("%s", str);
     printf("%dn", x);
     printf("%sn", str);
     return 0;
}

If I flush the stdout with fflush, the output results as intended.

--------------
Hey, fflush works... Still don't know exactly how. Maybe that's "another story to be told at another time"...
^_^
Thanks.