Task: | Merkkijono |
Sender: | viktor |
Submission time: | 2017-10-04 12:35:30 +0300 |
Language: | C++ |
Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main(int, char**)': input/code.cpp:7:39: error: invalid conversion from 'void*' to 'char*' [-fpermissive] char *str = calloc(1000, sizeof(char)); ^ input/code.cpp:10:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < strlen(str); i++){ ^ input/code.cpp:13:9: warning: statement has no effect [-Wunused-value] for(j; j != i; j--) ^ input/code.cpp:8:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", str); ^
Code
#include <stdio.h>#include <string.h>#include <stdlib.h>int main(int argc, char *argv[]){char *str = calloc(1000, sizeof(char));scanf("%s", str);int j = 0;for(int i = 0; i < strlen(str); i++){if(str[i] == str[i + 1]){for(j = i + 1; str[j] == str[j - 1]; j++);for(j; j != i; j--)str[j-1] = str[j];}}printf("%s", str);free(str);return 0;}