Code:
#include <stdio.h>
int pause(), add(int one, int two), convert2int(char string[]);
int main(){
char a[10];
char b[10];
char *p;
int uno;
int dos;
int result;
printf("Please enter a number: ");
if (fgets(a, sizeof(a), stdin) != NULL)
{
if ((p = strchr(a, '\n')) != NULL)
*p = '\0';
}
printf("Please enter another number: ");
if (fgets(b, sizeof(b), stdin) != NULL)
{
if ((p = strchr(b, '\n')) != NULL)
*p = '\0';
}
uno = convert2int(a);
dos = convert2int(b);
result = add(uno, dos);
printf("The number you entered is: %d\n",result);
pause();
return(0);
}
int pause(){
int move_on;
printf("Thanks for playing, press enter...");
//Get input until enter is pressed
move_on=getchar();
return(0);
}
int add(int one, int two){
int sum;
sum = one + two;
return(sum);
}
int convert2int(char string[]){
int converted;
converted = atoi(string);
return(converted);
}
Is this better? Or what problems have I created now? Thanks again for your feedback.