Unifix knowledge database - The original one

Dashboard - News - Search - List - About - Admin


Mike keder sig og Riis tåger

Author:mike - Wed Jun 22 14:26:24 2005

#include <stdio.h>
int findlastword(char *string,char *buffer)
{
        int i,c;
        c=0;
        for (i=0; i<=strlen(string); i++)
        {
                buffer[c]=string[i];
                c++;
                if (string[i]==' ') {c=0;}
        }
}
int main(void)
{
        char buffer[255],input[255];
        int inputsize;

        inputsize=0;

        while  ((input[inputsize] = getchar() ) != EOF)   
        { 
                if (inputsize<sizeof(input)) {  inputsize++;}
        }
        input[inputsize]=0;

        findlastword(input,buffer);
        printf("%s",buffer);
}

mike@workstation ~ $ cc lw.c -o lw
mike@workstation ~ $ echo Riis er en ost med salsa | ./lw    
salsa

Copyright(c) Unifix.org 2002-2011


Dashboard - News - Search - List - About - Admin
 
Powered by Mikjaer Consulting Solutions - Hosted by Specialhosting.dk