Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: [Syntax errors] Single app errors?!

Started 1 month, 1 week ago by dmpm
I am new to programming so i dont really understand why this isn't working for me. Any help would be brilliant. I have been given an application to make. The application is: "Write a program to read the number of units of electricity used by a consumer, and to write out the total cost, assuming the following rates : a. 5.2 p per unit for the first 100 units, b. 3.0 p per ...
Site: Dev Articles Forums - Programming Help and Tutorials for all developmenttechnologies  Dev Articles Forums - Programming Help and Tutorials for all developmenttechnologies - site profile
Forum: C/C++ Help  C/C++ Help - forum profile
Total authors: 2 authors
Total thread posts: 9 posts
Thread activity: no new posts during last week
Domain info for: devarticles.com

Other posts in this thread:

Icon replied 1 month, 1 week ago
You should probably include standard libraries like this: #include <stdio.h> Besides that, please post the errors warnings you are getting. We cannot reproduce them since we can have different compilers (and compiler settings).

dmpm replied 1 month, 1 week ago
Ok, i will try adding that library, should i take the other libraries out or just add the new one? My errors are: Code: error C2065: '“please' : undeclared identifier error C2146: syntax error : missing ')' before identifier 'enter' error C2059: syntax error : ')' error C2065: '“' : undeclared identifier error C2065: 'd”' : undeclared identifier ...

Icon replied 1 month, 1 week ago
There is no new library. I just suggested replacing your: #include "stdio.h" with #include <stdio.h> Although this is probably not your problem and I would actually recommend using #include <cstdio> but I am not sure if you are programming in C or C++. I see that you are using weird characters though. Do not use “ nor ” for quoting your string literals but use ...

dmpm replied 1 month, 1 week ago
Ok, thanks. The app ran when i changed from “ to " The application worked but the answer only flashes on then the application closes. What is the line i need to make it stay visible until a user presses a button? I tried what i thought it was but it has given me an error of: error C3861: 'system': identifier not found Anyway, this is what i thought it was Code: ...

Icon replied 1 month, 1 week ago
If you program in C++ then forget about stdio.h. Try the C++ way with iostream. system( "PAUSE" ) is a non-portable way of doing it, plus it uses an ugly system call. I guess you'd have to include stdlib.h to make it work? Not sure.. In c++ I just use: #include <iostream> std::cin.get();

dmpm replied 1 month, 1 week ago
I have just tried: #include <iostream> std::cin.get(); Using "std::cin.get();" has not given me an error but has not solved my problem. I have tried "system( "PAUSE" );" again after including iostream and this has solved my problem. My final code looks like this: Code: // Electricity consumed.cpp : Defines the entry point for the console ...

Icon replied 1 month, 1 week ago
Quick example of what I would more or less do: cpp Code: Original - cpp Code #include <iostream> using namespace std; int main() { int units; float total; cout << "Please enter units: "; ...

dmpm replied 1 month, 1 week ago
Quote: Originally Posted by Icon Quick example of what I would more or less do: cpp Code: Original - cpp Code #include <iostream> using namespace std; int main() { int units; ...

 

Top contributing authors

Name
Posts
dmpm
5
user's latest post:
[Syntax errors] Single app errors?!
Published (2009-11-03 13:25:00)
Quote: Originally Posted by Icon Quick example of what I would more or less do: cpp Code: Original - cpp Code #include &lt;iostream&gt; using namespace std; int main() { int units; float total; cout &lt;&lt; &quot;Please enter units: &quot;; cin &gt;&gt; units; cin.ignore(); // on linux this is probably not necessary..? if( cin ) { if( units &lt;= 100 ) { total = units * 5.2f; } else if( units &lt;= 400...
Icon
4
user's latest post:
[Syntax errors] Single app errors?!
Published (2009-11-03 12:58:00)
Quick example of what I would more or less do: cpp Code: Original - cpp Code #include &lt;iostream&gt; using namespace std; int main() { int units; float total; cout &lt;&lt; &quot;Please enter units: &quot;; cin &gt;&gt; units; cin.ignore(); // on linux this is probably not necessary..? if( cin ) { if( units &lt;= 100 ) { total = units * 5.2f; } else if( units &lt;= 400 ) { total = 520 + (units - 100)...

Related threads on "Dev Articles Forums - Programming Help and Tutorials for all developmenttechnologies":

Related threads on other sites:

Thread profile page for "[Syntax errors] Single app errors?!" on http://www.devarticles.com. This report page is a snippet summary view from a single thread "[Syntax errors] Single app errors?!", located on the Message Board at http://www.devarticles.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity