1.04.2006

I hate being sick

I think half the people i know are sick right now, which is probably why I am too. Everyone seems to accept the fact that you take medicine when you are sick. You dont feel well, you take something that will ease the symptoms. There is no cure, so all you can do is ease it a little bit. For some reason, I refuse to do so... This makes me feel and look sicker than everyone else. Why must i be so stubborn?

I stared at my computer all day today and felt like my eyes were going to pop out of my head. I did find one neat thing though. sometimes you come accross something that should be really easy, because its so simple, but you just have never done it before. This was one of those situations. I was writing a perl script and i thought it would be cool to prompt for the pw instead of hardcoding it. When i started coding, I realized that I had no idea how to turn the terminal echo off, in linux. Turns out it is very easy.

turn it off with:
stty -echo
turn it on with:
stty echo

simple as pie.

Here is a little C code that I wrote to demonstrate:

#include <stdlib.h>
#include <stdio.h>

int main(){
char p[10];

printf("Password:");

system("stty -echo");
fgets(p,10,stdin);
system("stty echo");
removeNewLine(p);

if(getLength(p) > 8){printf("Your password was longer than 8 characters...sorry!\n"); return 0;}
printf("\nYou entered %s as your password\n",p);
return 0;
}

int getLength(char *s){
int n = 0;
while(*s != '\0' && ++n)s++;
return n;
}

void removeNewLine(char *s){
while(*s != '\0'){if(*s == '\n'){*s = '\0';return;}s++;}
}

1 Comments:

Blogger w00tpro said...

One day we will change the world. But for now.. I'm sick of being sick.

12:18 PM  

Post a Comment

Links to this post:

Create a Link

<< Home