All pastes #515332 Raw Edit

Something

public text v1 · immutable
#515332 ·published 2007-05-28 04:08 UTC
rendered paste body
#include <stdio.h>

int main(void){
char name[20];

void strip_newline( char *str, int size )
{
    int i;
    /* remove the null terminator */
    for (  i = 0; i < size; ++i )
    {
        if ( str[i] == '\n' )
        {
            str[i] = '\0';
            /* we're done, so just exit the function by returning */
            return;   
        }
    }
    /* if we get all the way to here, there must not have been a newline! */
}

printf("What is your name?\n");
fgets(name, 20 , stdin);
strip_newline( name, 20 );

if ( name == "Frank\n") {
 printf("Your name is %s!\n", name); 
}
else {
 printf("I bet you wish your name was Frank!\n");
}

return 0;
}