• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 05:43
CET 11:43
KST 19:43
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets0$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)12Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822
StarCraft 2
General
SC2 Spotted on the EWC 2026 list? Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns Spontaneous hotkey change zerg Chinese SC2 server to reopen; live all-star event in Hangzhou
Tourneys
$25,000 Streamerzone StarCraft Pro Series announced $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) WardiTV Winter Cup WardiTV Mondays SC2 AI Tournament 2026
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes
Brood War
General
Potential ASL qualifier breakthroughs? BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion StarCraft & BroodWar Campaign Speedrun Quest Data analysis on 70 million replays
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Beyond All Reason Nintendo Switch Thread Awesome Games Done Quick 2026! Mechabellum Stormgate/Frost Giant Megathread
Dota 2
Official 'what is Dota anymore' discussion
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine Trading/Investing Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
My 2025 Magic: The Gathering…
DARKING
Physical Exercise (HIIT) Bef…
TrAiDoS
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2302 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
Next event in 1h 17m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 122
StarCraft: Brood War
Rain 5644
Sea 4507
Horang2 1326
Shuttle 659
Hyuk 535
Mini 441
Stork 394
actioN 279
Larva 275
ZerO 270
[ Show more ]
Leta 184
EffOrt 170
Mong 169
Soma 150
Zeus 122
Hyun 106
Light 103
ggaemo 93
Rush 91
Nal_rA 91
JulyZerg 90
910 67
Killer 64
hero 52
Mind 39
zelot 33
Sharp 29
Free 24
Sexy 21
Terrorterran 17
soO 17
scan(afreeca) 15
Sacsri 11
Noble 10
Bale 10
ajuk12(nOOB) 9
Dota 2
NeuroSwarm99
XcaliburYe98
ODPixel82
League of Legends
JimRising 464
C9.Mang0458
Counter-Strike
olofmeister1793
shoxiejesuss789
allub227
Super Smash Bros
Mew2King92
Other Games
summit1g7655
ceh9596
Pyrionflax303
Fuzer 180
ZerO(Twitch)9
Organizations
Other Games
gamesdonequick2971
StarCraft: Brood War
lovetv 3
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• naamasc21
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos2376
• Lourlo1158
• Stunt525
Upcoming Events
WardiTV Invitational
1h 17m
PiGosaur Cup
14h 17m
WardiTV Invitational
1d 1h
The PondCast
1d 23h
OSC
2 days
OSC
3 days
All Star Teams
3 days
INnoVation vs soO
sOs vs Scarlett
uThermal 2v2 Circuit
4 days
All Star Teams
4 days
MMA vs DongRaeGu
Rogue vs Oliveira
Sparkling Tuna Cup
4 days
[ Show More ]
OSC
5 days
Replay Cast
5 days
Wardi Open
6 days
Liquipedia Results

Completed

Proleague 2026-01-12
Big Gabe Cup #3
NA Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
OSC Championship Season 13
Underdog Cup #3
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

Escore Tournament S1: W4
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Thunderfire SC2 All-star 2025
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
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.