From e9b789f44ee73bef116a8d5939b3dd4840f45da1 Mon Sep 17 00:00:00 2001 From: csaez Date: Wed, 7 Jan 2015 18:56:25 -0300 Subject: [PATCH 1/2] fix for loop initial declarations --- src/c/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/c/main.c b/src/c/main.c index 62100cf..4983646 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -1,5 +1,4 @@ #include -#include #include const int MAX_ARGUMENT_COUNT = 3; @@ -7,7 +6,8 @@ const char* choices[] = {"rock", "paper", "scissors"}; const char* results[] = {"It's a tie", "Player 1 wins", "Player 2 wins"}; int input_id(const char* input) { - for(const char** choice = choices; choice < choices + sizeof(choices) / sizeof(choices[0]); ++choice) { + const char** choice; + for(choice = choices; choice < choices + sizeof(choices) / sizeof(choices[0]); ++choice) { if (strcmp(input, *choice) == 0) { return choice - choices; } @@ -21,9 +21,9 @@ int main(int argc, char* args[]) { return 1; } + int i; int pchoice[] = {0, 0}; -// for(char** arg = args + 1; arg < args + MAX_ARGUMENT_COUNT; ++arg) { - for(int i = 1; i < MAX_ARGUMENT_COUNT; ++i) { + for(i = 1; i < MAX_ARGUMENT_COUNT; ++i) { const int cindex = i - 1; pchoice[cindex] = input_id(args[i]); if (pchoice[cindex] < 0) { From e59830da9509bba064c5a04e4d2e9ca8af830380 Mon Sep 17 00:00:00 2001 From: Cesar Saez Date: Wed, 7 Jan 2015 19:03:34 -0300 Subject: [PATCH 2/2] spaces to tabs --- src/c/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c/main.c b/src/c/main.c index 4983646..3af94f4 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -6,7 +6,7 @@ const char* choices[] = {"rock", "paper", "scissors"}; const char* results[] = {"It's a tie", "Player 1 wins", "Player 2 wins"}; int input_id(const char* input) { - const char** choice; + const char** choice; for(choice = choices; choice < choices + sizeof(choices) / sizeof(choices[0]); ++choice) { if (strcmp(input, *choice) == 0) { return choice - choices; @@ -21,7 +21,7 @@ int main(int argc, char* args[]) { return 1; } - int i; + int i; int pchoice[] = {0, 0}; for(i = 1; i < MAX_ARGUMENT_COUNT; ++i) { const int cindex = i - 1;