Task: | ModAdd |
Sender: | idan |
Submission time: | 2016-09-24 15:01:17 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:17:19: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[15]' [-Wformat=] scanf("%s", &numA); ^ input/code.cpp:18:19: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[15]' [-Wformat=] scanf("%s", &numB); ^ input/code.cpp:37:21: error: '_strrev' was not declared in this scope puts(_strrev(result)); ^ input/code.cpp:38:16: error: 'system' was not declared in this scope system("Pause"); ^ input/code.cpp:17:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", &numA); ^ input/code.cpp:18:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", &numB); ^
Code
/********************************** Class: MAGSHIMIM C2 ** Week 1 ***********************************/#include <stdio.h>#include <math.h>#include <string.h>int main(void){int i = 0, currentAlsd = 0, currentBlsd = 0, currentDigit = 0;char numA[15] = { 0 };char numB[15] = { 0 };char result[15] = { 0 };scanf("%s", &numA);scanf("%s", &numB);int aIndex = strlen(numA) - 1;int bIndex = strlen(numB) - 1;int maxLength = strlen(numA) > strlen(numB) ? strlen(numA) : strlen(numB);//printf("MaxLength : %d", maxLength);//system("pause");for (i = 0; i < maxLength; i++){currentAlsd = aIndex < 0 ? 0 : numA[aIndex--] - '0';currentBlsd = bIndex < 0 ? 0 : numB[bIndex--] - '0';currentDigit = (currentAlsd + currentBlsd) % 10;result[i] = currentDigit + '0';//puts(result);//printf("iteration %d : A lsd: %d B lsd: %d", i, currentAlsd, currentBlsd);}puts(_strrev(result));system("Pause");}