Hi,
i'm totally new to c programming and i have just began writing code.What i want to make is a program that adds (and another one that subtracts) 2 numbers, =no matter how big they are= and i just can't do it.Can someone help?Below is the code that i wrote with some help:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void main()
{
int *a,*b,*c;
char buf[10000];
char buf2[10000];
int n, i;
printf("\nGive a number: ");
scanf("%s",buf);
n= strlen(buf);
printf("\n Number: %s \n",buf);
printf("Length of the number: %d \n ",n);
a=(int*)malloc(n*sizeof(int));
*a=atoi(buf);
/*for (i=0;i<n;i++){
a[i]=buf[n-i-1]-'0';
}*/
printf("\nGive a number: ");
scanf("%s",buf2);
n= strlen(buf2);
printf("\n Number: %s \n",buf2);
printf("Length of the number: %d \n ",n);
b=(int *) malloc(n*sizeof(int));
*b=atoi(buf2);
/*for (i=0;i<n;i++){
b[i]=buf2[n-i-1]-'0';
}*/
c=(int *) malloc(n*sizeof(int));
*c= *a-*b;
printf("\n First Number : %d \n",*a);
printf("\n Second Number : %d \n",*b);
printf("\n Result : %d \n",*c);
}
Thanx in advance!