• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 03:40
CET 08:40
KST 16:40
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT29Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (March 2-8): ByuN overcomes PvT block0GSL CK - New online series11BSL Season 224Vitality ends partnership with ONSYDE20Team Liquid Map Contest - Preparation Notice6
StarCraft 2
General
Weekly Cups (March 2-8): ByuN overcomes PvT block GSL CK - New online series Weekly Cups (Feb 23-Mar 1): herO doubles, 2v2 bonanza Vitality ends partnership with ONSYDE How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game?
Tourneys
RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) $5,000 WardiTV Winter Championship 2026 Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 516 Specter of Death Mutation # 515 Together Forever Mutation # 514 Ulnar New Year
Brood War
General
BSL 22 Map Contest — Submissions OPEN to March 10 BSL Season 22 BGH Auto Balance -> http://bghmmr.eu/ battle.net problems ASL21 General Discussion
Tourneys
ASL Season 21 Qualifiers March 7-8 [Megathread] Daily Proleagues BWCL Season 64 Announcement [BSL22] Open Qualifier #1 - Sunday 21:00 CET
Strategy
Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Simple Questions, Simple Answers Zealot bombing is no longer popular?
Other Games
General Games
Nintendo Switch Thread PC Games Sales Thread Path of Exile No Man's Sky (PS4 and PC) Stormgate/Frost Giant Megathread
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
Mexico's Drug War US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Gaming-Related Deaths
TrAiDoS
ONE GREAT AMERICAN MARINE…
XenOsky
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2047 users

C++ revision help! - Page 3

Blogs > konadora
Post a Reply
Prev 1 2 3 4 5 6 7 Next All
tec27
Profile Blog Joined June 2004
United States3702 Posts
June 28 2009 16:24 GMT
#41
Yeah, thats just the variable you'd be inputting their answer to.
Can you jam with the console cowboys in cyberspace?
konadora *
Profile Blog Joined February 2009
Singapore66358 Posts
June 28 2009 16:29 GMT
#42
I don't quite get how to use it, I got this -
#include <iostream>
using namespace std;

int main()
{
double c,f;
cout << "Please choose whether you are entering the temperature in Centigrade (c) or Farenheit (f)." << endl;
if(myChar == 'c'){
f = ((c*1.8)+32);
cout << "The temperature is " << f << " degrees Farenheit." << endl;
}
else if(myChar == 'f'){
c = ((f-32)*5/9);
cout << "The temperature is " << c << " degrees Centigrade." << endl;
}
return 0;
}


With these errors:

1>c:\users\user\documents\visual studio 2008\projects\p1\p1\p1.cpp(8) : error C2065: 'myChar' : undeclared identifier
1>c:\users\user\documents\visual studio 2008\projects\p1\p1\p1.cpp(12) : error C2065: 'myChar' : undeclared identifier
POGGERS
fusionsdf
Profile Blog Joined June 2006
Canada15390 Posts
June 28 2009 16:35 GMT
#43
On June 29 2009 00:49 Uligor wrote:
Show nested quote +
On June 29 2009 00:48 konadora wrote:
My next question:

What data type do I use if I want to use a fraction? I'm currently doing this exercise where I'm supposed to convert inputted Farenheit temperature into centigrade and vice versa, and I need to use the fraction 5/9.


float or double.


yes

at least one of the two numbers must be a float or double, or you must explicitly cast one to a double <static_cast> or integer division will be performed instead.

SKT_Best: "I actually chose Protoss because it was so hard for me to defeat Protoss as a Terran. When I first started Brood War, my main race was Terran."
Superbia
Profile Blog Joined April 2008
Netherlands8889 Posts
June 28 2009 16:38 GMT
#44
On June 29 2009 01:29 konadora wrote:
I don't quite get how to use it, I got this -
Show nested quote +
#include <iostream>
using namespace std;

int main()
{
double c,f;
cout << "Please choose whether you are entering the temperature in Centigrade (c) or Farenheit (f)." << endl;
if(myChar == 'c'){
f = ((c*1.8)+32);
cout << "The temperature is " << f << " degrees Farenheit." << endl;
}
else if(myChar == 'f'){
c = ((f-32)*5/9);
cout << "The temperature is " << c << " degrees Centigrade." << endl;
}
return 0;
}


With these errors:

Show nested quote +
1>c:\users\user\documents\visual studio 2008\projects\p1\p1\p1.cpp(8) : error C2065: 'myChar' : undeclared identifier
1>c:\users\user\documents\visual studio 2008\projects\p1\p1\p1.cpp(12) : error C2065: 'myChar' : undeclared identifier


The code in this case would be

#include <iostream>
using namespace std;

int main()
{
double value;
char myChar;

cout << "Please enter C (Centigrade) or F (Farenheit) followed by the appropriate value" << endl;
cin >> myChar >> value;

if(myChar == 'C')
cout << "The temperature is " << (value*1.8)+32 << " degrees Farenheit." << endl;
else if(myChar == 'F')
cout << "The temperature is " << (value-32)*5/9 << " degrees Centigrade." << endl;
else
cout << "Please insert a correct prefix" << endl;

return 0;
}


Please note how I replaced double f/c with double value and how I moved the calculations to inside the cout << instruction.
The example input for this piece of code would be "F 1.42". (note: this would be a rather unpleasant temperature)
Minimal effort.
konadora *
Profile Blog Joined February 2009
Singapore66358 Posts
Last Edited: 2009-06-28 16:42:50
June 28 2009 16:41 GMT
#45
The char is the same as 'int', except it is not just integers, but characters, that's all, right?

Also, the purpose of putting the calculations inside the cout << instruction would be to shorten the entire program, as well as to remove unnecessary variables, right?

Also, if you specify 'C' but the user types in 'c' instead (small C), then does it matter? I recall my teacher saying that caps matter a lot in programming.
POGGERS
Superbia
Profile Blog Joined April 2008
Netherlands8889 Posts
June 28 2009 16:45 GMT
#46
On June 29 2009 01:41 konadora wrote:
The char is the same as 'int', except it is not just integers, but characters, that's all, right?


char is 8 bit, int is 32 bit (though for int it's compiler specific). I think this might go a bit too far for now, you should use char to save single-byte characters (e.g. 'e', '0', etc).

On June 29 2009 01:41 konadora wrote:Also, the purpose of putting the calculations inside the cout << instruction would be to shorten the entire program, as well as to remove unnecessary variables, right?


Yeah, it's basically to remove unnecessary variables.
Minimal effort.
GHOSTCLAW
Profile Blog Joined February 2008
United States17042 Posts
Last Edited: 2009-06-28 16:46:55
June 28 2009 16:46 GMT
#47
oops.
PhotographerLiquipedia. Drop me a pm if you've got questions/need help.
konadora *
Profile Blog Joined February 2009
Singapore66358 Posts
June 28 2009 16:50 GMT
#48
Thanks for all the help for this noob here, I don't think I can keep awake anymore, already drank 4 cups of coffee. Will wake up in 6 hours' time and continue from there, going to get some sleep (almost 1am here). Thanks all once again!
POGGERS
okayokes
Profile Joined March 2004
United States39 Posts
June 28 2009 16:50 GMT
#49
On June 29 2009 01:41 konadora wrote:
The char is the same as 'int', except it is not just integers, but characters, that's all, right?

Also, the purpose of putting the calculations inside the cout << instruction would be to shorten the entire program, as well as to remove unnecessary variables, right?

Also, if you specify 'C' but the user types in 'c' instead (small C), then does it matter? I recall my teacher saying that caps matter a lot in programming.



char holds one ASCII character iirc. If you want a sentence you should use a string. Though you could also use a character array.

char myChar[] = {'H', 'e', 'l', 'l', 'o'};

string myString = "Hello";
-,-
Superbia
Profile Blog Joined April 2008
Netherlands8889 Posts
Last Edited: 2009-06-28 16:59:17
June 28 2009 16:55 GMT
#50
On June 29 2009 01:35 fusionsdf wrote:
Show nested quote +
On June 29 2009 00:49 Uligor wrote:
On June 29 2009 00:48 konadora wrote:
My next question:

What data type do I use if I want to use a fraction? I'm currently doing this exercise where I'm supposed to convert inputted Farenheit temperature into centigrade and vice versa, and I need to use the fraction 5/9.


float or double.


yes

at least one of the two numbers must be a float or double, or you must explicitly cast one to a double <static_cast> or integer division will be performed instead.



With the code "(value-32)*5/9" (value being double) the compiler (MSVS08) generated FPU instructions for 5/9, so in this case it was not necessary. However I see your concern because compilers like to precalculate things.
Minimal effort.
Divinek
Profile Blog Joined November 2006
Canada4045 Posts
June 28 2009 17:07 GMT
#51
are you in uni for a class or something? if you are im a bit confused how you dont understand any of this. If it's a highschool class or something then maybe i get it but some of this stuff you are asking is like first few weeks of learning. I'm just honestly curious not trying to be a dick
Never attribute to malice that which can be adequately explained by stupidity.
Oh goodness me, FOX tv where do you get your sight? Can't you keep track, the puck is black. That's why the ice is white.
konadora *
Profile Blog Joined February 2009
Singapore66358 Posts
June 28 2009 17:20 GMT
#52
I'm in high school, started 3 months ago, but I had gotten sick around March (which was the period where my sudden burst in activeness on TL occurred), missing school for a month, after which I failed to revise enough lol.

Not to mention the one month summer break (which ended today) made me just slack all the way.
POGGERS
Scorch
Profile Blog Joined March 2008
Austria3371 Posts
June 28 2009 17:35 GMT
#53
Looks like you are trying to teach yourself programming from scratch without any guidance. That's hard. You should look for a C++ tutorial which explains the basics in an understandable and structured manner. Posing random questions on a very specific problem without quite understanding the answers won't help you much. Especially since those who give advice often look at the problem from a higher level that you don't even need yet. For example, I've seen people talk about compiler settings here, which isn't what you want to know at all and will only confuse you.
You won't make it far without knowing basic concepts like control structures, data types, return values etc. So you should try and learn those basics and then come back if any questions remain. Also, it's far easier for a beginner to modify and extend existing code than to write it yourself.
unknown.sam
Profile Joined May 2007
Philippines2701 Posts
June 28 2009 17:53 GMT
#54
On June 29 2009 02:35 Scorch wrote:
Looks like you are trying to teach yourself programming from scratch without any guidance. That's hard. You should look for a C++ tutorial which explains the basics in an understandable and structured manner. Posing random questions on a very specific problem without quite understanding the answers won't help you much. Especially since those who give advice often look at the problem from a higher level that you don't even need yet. For example, I've seen people talk about compiler settings here, which isn't what you want to know at all and will only confuse you.
You won't make it far without knowing basic concepts like control structures, data types, return values etc. So you should try and learn those basics and then come back if any questions remain. Also, it's far easier for a beginner to modify and extend existing code than to write it yourself.

this
"Thanks for the kind words, but if SS is the most interesting book you've ever read, you must have just started reading a couple of weeks ago." - Mark Rippetoe
AoN.DimSum
Profile Blog Joined September 2008
United States2983 Posts
June 28 2009 18:03 GMT
#55
http://cplusplus.com/ is a good site
by my idol krokkis : "U better hope Finland wont have WCG next year and that I wont gain shitloads of skill, cause then I will wash ur mouth with soap, little man."
okayokes
Profile Joined March 2004
United States39 Posts
Last Edited: 2009-06-28 18:23:06
June 28 2009 18:18 GMT
#56
cool site. C++ seems confusing at first but it gets alot easier over time. Certain things I'm trying to learn now are hard to get my head around. Like recursion <_>;

code like this can be hard to get a grip on (atleased for me):

void permute(string current, string rest)
{
if (rest == "")
{
cout << current << endl;
++counter;
}else{
for ( int i = 0; i < rest.length(); i++ )
{
string next = current + rest[i];
string remaining = rest.substr(0, i)
+ rest.substr(i+1);
permute(next, remaining);
}
}
}

the syntax itself is not the difficult aspect, but keeping track of every stack frame and how it unravels is difficult ~_~. There are some great stanford lectures posted up on youtube though! http://www.youtube.com/profile?user=stanforduniversity&view=playlists

Programming Methodology is the beginners course using mostly Java.
Programming Abstractions is the intermediate course using C++
Programming Paradigms is the advanced course which I haven't looked at.
-,-
DrLefTy
Profile Blog Joined June 2009
United States36 Posts
June 28 2009 18:53 GMT
#57
if you want to learn recursion, learn how to code in lisp or scheme.
fusionsdf
Profile Blog Joined June 2006
Canada15390 Posts
Last Edited: 2009-06-28 20:59:03
June 28 2009 20:53 GMT
#58
On June 29 2009 01:41 konadora wrote:
Also, if you specify 'C' but the user types in 'c' instead (small C), then does it matter? I recall my teacher saying that caps matter a lot in programming.


since nobody answered this: yes, case matter Variable is different from VARIABLE and vArIaBlE. Generally constants are in all CAPS, normal variables are lowercase with either underscores between words like_this_variable or camel case likeThisVariable. Struct and Class names tend to have the first letter capitalized.

Its really important to stay consistent throughout your code.
SKT_Best: "I actually chose Protoss because it was so hard for me to defeat Protoss as a Terran. When I first started Brood War, my main race was Terran."
eci
Profile Joined July 2008
Germany45 Posts
June 28 2009 21:45 GMT
#59
back to the question void main() and int main() - int main() starts an application which returns an int number ( -2^31..(2^31-1) ) while void main() always returns 0. How this returned value depends on your operating system, on linux you can see that result code e.g. by "echo $?" on bash command line.
I think void main() is also not in the recent standard any more, so if you do not know for sure just use "int main()" and don't forget to return a value ( return 0; - you could also write return -1; if an error happend - but its kind of old school )

Btw: This question is rather unimportant - try to write more code - implement some algorithms ( e.g. bread death search in a graph ) - use stl standard library - use external librarys like boost

hf in coding
Vorwaerts!
liquorice
Profile Joined August 2008
United States170 Posts
June 28 2009 23:19 GMT
#60
On June 29 2009 05:53 fusionsdf wrote:
Show nested quote +
On June 29 2009 01:41 konadora wrote:
Also, if you specify 'C' but the user types in 'c' instead (small C), then does it matter? I recall my teacher saying that caps matter a lot in programming.


since nobody answered this: yes, case matter Variable is different from VARIABLE and vArIaBlE. Generally constants are in all CAPS, normal variables are lowercase with either underscores between words like_this_variable or camel case likeThisVariable. Struct and Class names tend to have the first letter capitalized.

Its really important to stay consistent throughout your code.


camel notation ftw. there's also another one that has the type in the variable name, but it's fallen out of favour.
fuck yeah zerglings!
Prev 1 2 3 4 5 6 7 Next All
Please log in or register to reply.
Live Events Refresh
OSC
00:00
OSC Elite Rising Star #18
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 174
ProTech134
StarCraft: Brood War
Shuttle 413
Leta 123
Larva 98
Aegong 94
Hyun 81
ToSsGirL 72
Shine 50
Sharp 45
yabsab 43
910 9
[ Show more ]
Light 0
Dota 2
NeuroSwarm120
League of Legends
JimRising 537
Counter-Strike
Stewie2K803
m0e_tv571
Other Games
summit1g9159
WinterStarcraft484
C9.Mang0313
Happy199
Mew2King62
Organizations
Dota 2
PGL Dota 2 - Main Stream934
Other Games
gamesdonequick790
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 11 non-featured ]
StarCraft 2
• Berry_CruncH48
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Wardi Open
4h 20m
PiGosaur Monday
16h 20m
GSL
1d 2h
WardiTV Team League
1d 4h
The PondCast
2 days
WardiTV Team League
2 days
Replay Cast
2 days
Replay Cast
3 days
CranKy Ducklings
4 days
WardiTV Team League
4 days
[ Show More ]
uThermal 2v2 Circuit
4 days
BSL
4 days
Sparkling Tuna Cup
5 days
WardiTV Team League
5 days
BSL
5 days
Replay Cast
5 days
Replay Cast
6 days
Wardi Open
6 days
Monday Night Weeklies
6 days
Liquipedia Results

Completed

ASL Season 21: Qualifier #2
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
Spring Cup 2026
BSL Season 22
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
Acropolis #4
IPSL Spring 2026
CSLAN 4
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
NationLESS Cup
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.