I am programming using C++, using Microsoft Visual Studio 2005.
here are the errors:
j:\hw2\hw2a-ssabdelm.cpp(23) : error C2143: syntax error : missing ')' before ';'
j:\hw2\hw2a-ssabdelm.cpp(23) : error C2563: mismatch in formal parameter list
j:\hw2\hw2a-ssabdelm.cpp(23) : error C2100: illegal indirection
j:\hw2\hw2a-ssabdelm.cpp(23) : error C2059: syntax error : ')'
j:\hw2\hw2a-ssabdelm.cpp(23) : warning C4552: '*' : operator has no effect; expected operator with side-effect
Build log was saved at "file://c:\Documents and Settings\Sam %26amp; Jacqueline\My Documents\Visual Studio 2005\Projects\hw2-ssabdelm\hw2-ssabdelm\...
hw2-ssabdelm - 4 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Why do I get compiler errors when I type: "vlt = sin*(2*pi*freq * time);"?
Take out the *
vlt = sin(2*pi*freq*time);
And remove the semicolon from your #define for pi (which should be upper case anyway):
#define PI 3.14
Reply:sin is a math function which has the following prototype:
double sin(double x);
so as an obvious syntax error its easy to see you are incorrectly adding in a '*' between sin and its parameter.
The line should have the '*' after the sin function removed in order for the parameter to be properly accepted.
vlt = sin(2*pi*freq*time);
Hope that helps.
--------------------------------------...
You still have a problem now that you've paste the code with your preprocessor define
eg: #define pi 3.14;
used with : vlt = sin*(2*pi*freq * time);
becomes : vlt = sin*(2*3.14;*freq * time);
The semi-colon will cause a syntax error, therefore the define should not have it in there eg
#define pi 3.14
is all you need.
Reply:I think you need to write sin(x), not sin*(x).
Reply:syntax error: there should be no * between sin and bracket. I t should be vlt = sin(2*pi*freq * time);
Reply:Take out the ; from in front fo the " and put it behind it.
Reply:Well I assume you are intending to use the Sine function...
your line should read vlt = sin(2*pi*freq*time);
- you have a star (*) between sin and the opening parenthesis which I believe is causing at least some of your problems..
You may also want to make sure the other terms in your expression are correctly defined and watch out for the 2.. it will be interpreted as an integer which may cause the other terms to be truncated to integers I.E. It becomes sin( 2 * 3 * freq * time ) which I'm fairly sure is not what you want.
Hope this helps.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment