Error Syntax Error Before
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta syntax error before erlang Discuss the workings and policies of this site About Us Learn more
Syntax Error Before Token
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack syntax error before ' ' token in c Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping erlang syntax each other. Join them; it only takes a minute: Sign up syntax error before ';' token up vote 0 down vote favorite I wrote a quick program (Calculating wages) to help me stay up to speed. For some reason when I compile this I keep getting the error "53: syntax error before ';' token" #include
int main() { #define week 7; #define year 365; int jan,feb,mar,apr,may,june,july,aug,sep,oct,nov,dec; int wage; /* Upgrade to float in future */ char input,month; int holder; jan=mar=may=july=aug=oct=dec=31; apr=june=sep=nov=30; feb=28; for(;;) { if(input='y') { #define YEAR 366; break; } else if(input='n') { break; } else { printf("Unable to understand input"); } } printf("Enter wage/day in pounds.\n?\n"); scanf("%d",&wage); /* unsure if I need to get string and then use atoi */ printf("Wage per day:\t%d\n",wage); printf("Wage per week:\t%d\n",wage*7); printf("Wage per month:\t%d\n",wage*30); holder=YEAR; printf("Wage per year:\t%d\n",wage*holder); printf("As months have varying day amounts, if you wish to view a specific month type:\n"); printf("A-Jan\nB-Feb\nC-Mar\nD-Apr\nE-May\nF-June\nG-July\nH-Aug\nI-Sep\nJ-Oct\nK-Nov\nL-Dec\nor type X-to EXIT"); month=getchar(); if((month=='A')||(month=='C')||(month=='E')||(month=='G')||(month=='H')||(month=='J')||(month=='L')){ printf("Wage for this month will be:\t%d",wage*31); } else if((month=='D')||(month=='F')||(month=='I')||(month=='K')){ printf("Wage for this month will be:\t%d",wage*30); } else if((month=='B')&&(year==365)){ printf("Wage for this month will be:\t%d",wage*28); } else if((month=='B')&&(year==366)){ printf("Wage for this month will be:\t%d",wage*29); } else if(month=='X'){ exit(1); } return 0;
} No matter how many times I read through it I just can't manage to see what I'm doing incorrectly. As a side note, if anybody feels like screaming/givinghere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Erlang getting error ** 1: syntax error before: '->' ** up vote 12 down vote favorite 3 I have started some hands on in Erlang and I am getting : ** 1: syntax http://stackoverflow.com/questions/20228713/syntax-error-before-token error before: '->' ** whenever i am declaring any function for eg. to calculate sum of a list (this is experimental, of cource there is Built In Function for find sum of a list). sum([]) -> 0; sum([H | T]) -> H + sum(T). in erl shell (v 5.5.5). Thanks in advance erlang share|improve this question edited Sep 4 '10 at 19:56 user113716 207k41341382 asked Aug 31 '10 at 19:46 pranjal 411417 add a comment| 3 Answers 3 active oldest http://stackoverflow.com/questions/3612628/erlang-getting-error-1-syntax-error-before votes up vote 32 down vote accepted You can't define functions in the shell using the same syntax as in an erl file. You can define fun's though. Syntax in the shell needs to be: Sum = fun([], _) -> 0; ([H | T], F) -> H + F(T, F) end, Sum([1,2,3], Sum). Note that recursive anonymous functions (which this is) are defined in an ugly way. You basically have to pass the function as an argument to itself. share|improve this answer answered Aug 31 '10 at 22:32 Daniel Luna 1,5611013 3 aka: want functions in shell? Have fun! –Manoj Govindan Sep 1 '10 at 4:14 I wish the error message was more helpful. –dotslash Jul 25 at 4:52 add a comment| up vote 8 down vote The straight answer is that in a module definition file you have attributes, like -module()., -export(). etc, and function definitions, while in the shell you enter expressions to be evaluated. A function definition is not an expression. If you want to define a local, temporary function in the shell you need to use fun's as @DanielLuna has shown. These are really anonymous unnamed functions so calling themselves recursively is a pain, which is not specific to Erlang but common to all anonymous functions. N.B. Sum = fun([], _) -> 0; ([H | T], F) -> H + F(T, F) end. in shell does NOT define a functio
parse error at..., parse error before... This is a general-purpose syntax error. It is frequently caused by a missing http://crasseux.com/books/ctutorial/parse-error-at....html semicolon. For example, the following code: #include
topic ForumsMembersHelp Files Developer Journals Gallery Calendar Downloads Resources Store Classifieds Tracker Links Home For Beginners Articles All Articles Post an Article Technical Game Programming General Programming Graphics Programming and Theory DirectX and XNA OpenGL and Vulkan Multiplayer and Network Programming Artificial Intelligence Math and Physics Mobile Development Middleware, Libraries, and Tools Virtual and Augmented Reality Creative Game Design Music and Sound Visual Arts Business Breaking into the Industry Production and Management Interviews Business and Law Event Coverage Forums All Forums Technical Game Programming General Programming Graphics Programming and Theory DirectX and XNA OpenGL & Vulkan Multiplayer and Network Programming Artificial Intelligence Math and Physics Mobile & Console Development Build Systems & Source Control Middleware, Libraries, and Tools Virtual and Augmented Reality Creative Game Design Writing For Games Music and Sound Visual Arts Gallery Business Breaking into the Industry Business & Law Production & Management Community GDNet Lounge Coding Horrors Article Writing Comments, Suggestions and Ideas Your Announcements Hobby Project Classifieds Indie Project Showcase Community Developer Journals Gallery Classifieds Jobs Freelancers Hobby Projects GDNet+ Membership Store Marketplace Newsletter » Home » Forums » The Technical Side » For Beginners Chat Watched Content New Content 0 Need Help : error: syntax error before `*' token Started by pandaraf, Apr 18 2012 09:41 AM SDL sdl MinGW SDL_mixer Old topic! Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic. You cannot reply to this topic 3 replies to this topic #1 pandaraf Members -Reputation: 108 Like 0Likes Like Posted 18 April 2012 - 09:41 AM Until this topic posted, i didn't found the solution. This thing made me told there's something wrong in the MinGW Developer Studio. Or perharps, it's only my depression .This is the codes i wrote