By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

Getting the error "expected identifier or '(' before '{' token in C

P: 2
As shown in the attachment, I'm getting the error "expected identifier or '(' before '{' token in C, can anyone help me with this error? I'm using Code::Blocks 13.12

Expand|Select|Wrap|Line Numbers
  1. #define md1(i, m, n)
  2. {
  3.     factor= 1+i/m;
  4.     ratio=(12/m)*(pow(factor,m*n)-1)/(i/m);
  5. }
  6. #define md2(i, m, n)
  7. {
  8.     factor= 1+i/m;
  9.     ratio=(pow(factor,m*n)-1)/(pow(factor,m/12)-1);
  10. }
  11. #define md3(i, n)
  12. {
  13.     ratio=(exp(i*n)-1)/(exp(i/12)-1);
  14. }
  15.  
  16.  

Attached Images
File Type: jpg error.jpg (53.8 KB, 1066 views)
Nov 14 '15 #1

✓ answered by Clearner321

For a multi-line define use the line-continuation character, \.
Your code will then look something like this
Expand|Select|Wrap|Line Numbers
  1. #define md1(i, m, n)\
  2. { \
  3. factor= 1+i/m;\
  4. ratio=(12/m)*(pow(factor,m*n)-1)/(i/m); \
  5. )
  6.  

Share this Question
Share on Google+
2 Replies


P: 22
For a multi-line define use the line-continuation character, \.
Your code will then look something like this
Expand|Select|Wrap|Line Numbers
  1. #define md1(i, m, n)\
  2. { \
  3. factor= 1+i/m;\
  4. ratio=(12/m)*(pow(factor,m*n)-1)/(i/m); \
  5. )
  6.  
Nov 14 '15 #2

P: 2
Thank you Clearner321, its running perfectly now.
Nov 15 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.