Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int convert(char* number)
- {
- int nr = 0;
- for(int i = 0; number[i] != '\0'; ++i)
- nr = nr * 10 + number[i] - 48;
- return nr;
- }
- int main()
- {
- char number[50];
- int nr, sum = 0;
- FILE * input;
- input = fopen("ini.txt","r");
- if( input )
- {
- while(fscanf(input, "%s", number) != EOF)
- {
- nr = convert(number);
- sum += nr;
- }
- }
- printf("Suma numerelor este: %d\n", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement