Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22070

CODEBLOCKS : a function-definition is not allowed here before '{' [closed]

$
0
0
#ifndef ISVALID_H_INCLUDED#define ISVALID_H_INCLUDEDint is_valid_name(char* c){  //ERROR IS HERE    for(unsigned int i = 0; i < strlen(c); i++)    {        /// first character        if(!strcasecmp(&c[0], "_") || !isalpha(c[0]))        {            return 0;        }        /// rest of the characters        if(!isalnum(c[i]))        {            return 0;        }    }    return 1;}int isOperator(char c){    switch(c)    {    case('^'):    case('*'):    case('/'):    case('+'):    case('-'):        return 1;    default:        return 0;    }}#endif // ISVALID_H_INCLUDED

I guess the title says it all, i have this library called "isValid.h" in part of a bigger project , and it was working just fine idk what happened suddenly it stopped working. PS(iam a new programmer just in case this is a newbie mistake) thanks in advance.
EDIT: HERE IS MORE CODE FOR MY MAIN FUNCTION WITH GIVES AN ERROR 'expected } at the end of input' at LINE 30

#include <iostream>#include<cstdio>#include"variableStack.h"#include"helperFunctions.h"#include"isValid.h"#include "AVL.h"using namespace std;int main(){    BinarySearchTree *bst= createNewTree();    char s[20]; while(strcasecmp(s,"EXIT")!=0) {     printf("ENTER STATMENT>>>");     char** myMatrix = splitString(gets(s));    if(isPreEqualValid(myMatrix[0])&&isPostEqualValid(myMatrix[1]))    {        float evaluation=ifpfv(myMatrix[1]);        char* token = strtok(myMatrix[0], "=");            while (token != NULL) {            Insert(bst,newVariable(evaluation,token));            token = strtok(NULL, "=");    }    } }return 0;}

this is the helper functions .h

#ifndef HELPERFUNCTIONS_H_INCLUDED#define HELPERFUNCTIONS_H_INCLUDED#include"AVL.h"#include"iftpf.h"float ifpfv(char* infix){    int i;    char *nospaces = deblank(infix);    length = strlen(nospaces);    postfixlength = length;    char postfix[length + 100];    infixToPostfix(nospaces, postfix);    char realpostfix[postfixlength + 1];    for(i = 0; i < postfixlength; i++)    {        realpostfix[i] = postfix[i];    }    realpostfix[i]='\0';    return evaluatePostfix(realpostfix);}float evaluate(char* postEqual ,BinarySearchTree* tree){    char myCopy[strlen(postEqual)+1];    strcpy(myCopy,postEqual);    treeNode *searchResult;    char* token = strtok(myCopy, "+-*/^");            while (token != NULL) {            searchResult=searchTree(tree,token);            if(!searchResult){printf("Variable '%s' was used without decalartion\n",token);return NULL;}            else            {                token = strtok(NULL, "+-*/^");            }}#endif // HELPERFUNCTIONS_H_INCLUDED

Viewing all articles
Browse latest Browse all 22070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>