All pastes #513149 Raw Edit

LordBoBCUP

public c v1 · immutable
#513149 ·published 2007-05-27 04:13 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>		    int main() {    char strInput[2];    int nLoop, intInput, c;    int fib_array[999];    int result, loop, error, temp;    error = 0;	while (error != 1){		error = 0;		printf("Which Fibonacci rank?\n");		printf("Input: ");		for (loop = 0; (c = getchar()) != EOF && c != '\n' && loop < 2; loop++){			if (c >= '0' && c <= '9'){				strInput[loop] = c;			}			else			{				error = 1;			}		}		if (error == 1){			printf("Output: Wrong Input\n");			error = 0;		} else {			break;		}	}	temp = stringToInt(strInput);	printf("%d", temp);    if (*strInput == '0'){	exit(0);    }    if (*strInput == '1'){	printf("1\n");	exit(0);    }    fib_array[0] = 0;    fib_array[1] = 1;//    for (nLoop = 2; nLoop < nTimes+1; ++nLoop) {//        fib_array[nLoop] = fib_array[nLoop-1] + fib_array[nLoop-2];//        printf("%d ", fib_array[nLoop] );//    }    printf("\n");    return 0;}int stringToInt( char *src ) {	int sign = +1;	int result = 0;	if ( *src == '-' ) {		sign = -1;		src++;		}	else if ( *src == '+' ) {		src++;		}	while ( *src != '\0' )		result = result * 10 + *src++ - '0';	return sign * result;}