I am trying to write a math engine. So far, I'm still working on the addition portion of the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void whatOperation(void);
void add(char[], char[]);
int main (void) {
printf("Welcome to the NumberChopper!\n\n\n\n");
whatOperation();
return 0;
}
//find out which function to execute
void whatOperation(void) {
char functionRead[1000];
char addFunction[1000]=" add";
printf("Please enter the function with parameters: ");
scanf("%s", &functionRead);
if(strncmp(functionRead, addFunction, 4)==1) {
add(functionRead, addFunction);
}
else {
printf("Hey you! Don't fall asleep at the keyboard! \n");
printf("%s", addFunction);
}
}
//add function
int countCharacters(char functionRead) {
int charactersInInput=0;
while(functionRead[charactersInInput]!="\n") {
charactersInInput++;
}
return charactersInInput++;
}
void add (char functionRead[], char addFunction[]) {
printf("Add function successfully acessed.\n");
//Pointers
char *functionReadPtr=functionRead+7;
int charactersInInput=0;
char *testPointer = functionRead;
char integers[1000];
printf("Test pointer: %s \n", testPointer);
printf("Parameter pointer: %s \n", functionReadPtr );
}
When I build it with CodeLite I get:
Code:
C:/Documents and Settings/Dhaivat Pandya/Desktop/helloWorld.c/NumberChopper/NumberChopper.c: In function `countCharacters':
C:/Documents and Settings/Dhaivat Pandya/Desktop/helloWorld.c/NumberChopper/NumberChopper.c:32: error: subscripted value is neither array nor pointer
mingw32-make.exe[1]: *** [Debug/NumberChopper.o] Error 1
mingw32-make.exe: *** [All] Error 2
----------Build Ended----------
1 errors, 0 warnings
I don't understand the problem