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

Error problem

P: 37
hey i did this code and i keep getting this error:

syntax error before `;' token

in this part of the code:

Expand|Select|Wrap|Line Numbers
  1.  (in.read (&c, 1);
this is my code:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     ifstream in ("English.txt");
  11.     if(!in)
  12.     {cout<<"Sorry cannot open the file!!";}
  13.  
  14.     system("pause");
  15.     return 1;
  16.  
  17.  
  18.  
  19.      ofstream out ("Morse.txt");
  20.      char c;
  21.      string s;
  22.      while(in)
  23.      (in.read (&c, 1);
  24.      if(c=='A') s=".-";
  25.      if(c=='B') s="-...";
  26.      if(c=='C') s="-.-.";
  27.      if(c=='D') s="-..";
  28.      if(c=='E') s=".";
  29.      if(c=='F') s="..-.";
  30.      if(c=='G') s="--.";
  31.      if(c=='H') s="....";
  32.      if(c=='I') s="..";
  33.      if(c=='J') s=".---";
  34.      if(c=='K') s="-.-";
  35.      if(c=='L') s=".-..";
  36.      if(c=='M') s="--";
  37.      if(c=='N') s="-.";
  38.      if(c=='O') s="---";
  39.      if(c=='P') s=".--.";
  40.      if(c=='Q') s="--.-";
  41.      if(c=='R') s=".-.";
  42.      if(c=='S') s="...";
  43.      if(c=='T') s="-";
  44.      if(c=='U') s="..-";
  45.      if(c=='V') s="...-";
  46.      if(c=='W') s=".--";
  47.      if(c=='X') s="-..-";
  48.      if(c=='Y') s="-.--";
  49.      if(c=='Z') s="--..";
  50.      if(c=='1') s=".----";
  51.      if(c=='2') s="..---";
  52.      if(c=='3') s="...--";
  53.      if(c=='4') s="....-";
  54.      if(c=='5') s=".....";
  55.      if(c=='6') s="";
  56.      if(c=='7') s="-....";
  57.      if(c=='8') s="--...";
  58.      if(c=='9') s="---..";
  59.      if(c=='0') s=".....";
  60.      if(c=='\n') s="\n";
  61.  
  62.     (char*)(&s[0], s.length());
  63.      out.write(" ",1);
  64.      in.close();
  65.      out.close();
  66.    system("pause");
  67. }

Thanks,

Carly
Nov 12 '06 #1
Share this Question
Share on Google+
2 Replies


10K+
P: 13,264
hey i did this code and i keep getting this error:

syntax error before `;' token

in this part of the code:

Expand|Select|Wrap|Line Numbers
  1.  (in.read (&c, 1);
this is my code:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4. #include <string.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. ifstream in ("English.txt");
  11. if(!in)
  12. {cout<<"Sorry cannot open the file!!";}
  13.  
  14. system("pause");
  15. return 1;
  16.  
  17.  
  18.  
  19. ofstream out ("Morse.txt");
  20. char c;
  21. string s;
  22. while(in)
  23. (in.read (&c, 1);
  24. if(c=='A') s=".-";
  25. if(c=='B') s="-...";
  26. if(c=='C') s="-.-.";
  27. if(c=='D') s="-..";
  28. if(c=='E') s=".";
  29. if(c=='F') s="..-.";
  30. if(c=='G') s="--.";
  31. if(c=='H') s="....";
  32. if(c=='I') s="..";
  33. if(c=='J') s=".---";
  34. if(c=='K') s="-.-";
  35. if(c=='L') s=".-..";
  36. if(c=='M') s="--";
  37. if(c=='N') s="-.";
  38. if(c=='O') s="---";
  39. if(c=='P') s=".--.";
  40. if(c=='Q') s="--.-";
  41. if(c=='R') s=".-.";
  42. if(c=='S') s="...";
  43. if(c=='T') s="-";
  44. if(c=='U') s="..-";
  45. if(c=='V') s="...-";
  46. if(c=='W') s=".--";
  47. if(c=='X') s="-..-";
  48. if(c=='Y') s="-.--";
  49. if(c=='Z') s="--..";
  50. if(c=='1') s=".----";
  51. if(c=='2') s="..---";
  52. if(c=='3') s="...--";
  53. if(c=='4') s="....-";
  54. if(c=='5') s=".....";
  55. if(c=='6') s="";
  56. if(c=='7') s="-....";
  57. if(c=='8') s="--...";
  58. if(c=='9') s="---..";
  59. if(c=='0') s=".....";
  60. if(c=='\n') s="\n";
  61.  
  62. (char*)(&s[0], s.length());
  63. out.write(" ",1);
  64. in.close();
  65. out.close();
  66. system("pause");
  67. }

Thanks,

Carly
Count the brackets. Two ( against one ) in that line.
Nov 12 '06 #2

P: 37
Gosh what a foolish mistake..............thanks r035198x !!!!!!!!!!!!

carly
Nov 12 '06 #3

Post your reply

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