• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:56
CEST 19:56
KST 02:56
  • 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
[ASL21] Ro8 Preview Pt2: Progenitors1Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists22
Community News
RSL Revival: Season 5 - Qualifiers and Main Event10Code S Season 1 (2026) - RO12 Results02026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced92026 GSL Tour plans announced15
StarCraft 2
General
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Code S Season 1 (2026) - RO12 Results Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool MaNa leaves Team Liquid
Tourneys
RSL Revival: Season 5 - Qualifiers and Main Event GSL Code S Season 1 (2026) SC2 INu's Battles#15 <BO.9 2Matches> WardiTV Spring Cup SEL Masters #6 - Solar vs Classic (SC: Evo)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base Mutation # 521 Memorable Boss
Brood War
General
Why there arent any 256x256 pro maps? [ASL21] Ro8 Preview Pt2: Progenitors BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion
Tourneys
[Megathread] Daily Proleagues [ASL21] Ro8 Day 2 Escore Tournament StarCraft Season 2 [BSL22] RO16 Group Stage - 02 - 10 May
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Nintendo Switch Thread Daigo vs Menard Best of 10 Diablo IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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 TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Movie Stars In Video Games: …
TrAiDoS
ramps on octagon
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2066 users

The Big Programming Thread - Page 55

Forum Index > General Forum
Post a Reply
Prev 1 53 54 55 56 57 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2011-05-22 22:26:37
May 22 2011 21:57 GMT
#1081
On May 19 2011 23:03 Greggle wrote:
Hey guys, I hate to do this, but I've got an assignment due in a few hours. I wrote a C++ program in Dev-C++, and it compiles with no errors or warnings. The professor though always tests it by compiling it on linux with g++ though. I can't get my makefile to work for shit though.

The Dev-C++ makefile for windows is:
+ Show Spoiler +
# Project: lab7
# Makefile created by Dev-C++ 4.9.9.2

CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES =
OBJ = main.o gstack.o gqueue.o $(RES)
LINKOBJ = main.o gstack.o gqueue.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib"
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
BIN = lab7.exe
CXXFLAGS = $(CXXINCS)
CFLAGS = $(INCS)
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before lab7.exe all-after


clean: clean-custom
${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o "lab7.exe" $(LIBS)

main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)

gstack.o: gstack.cpp
$(CPP) -c gstack.cpp -o gstack.o $(CXXFLAGS)

gqueue.o: gqueue.cpp
$(CPP) -c gqueue.cpp -o gqueue.o $(CXXFLAGS)


The one I made for gcc in linux is (based on my extremely poor knowledge of makefiles):
+ Show Spoiler +
prog : main.cpp gqueue.o gqueue.h gstack.o gstack.h
g++ main.cpp -omain gqueue.o gstack.o
gqueue.o : gqueue.cpp gqueue.h
g++ gqueue.cpp gqueue.h -c -o gqueue.o
gstack.o : gstack.cpp gstack.h
g++ gstack.cpp gstack.h -c -o gstack.o


Can anyone help me translate it to Linux properly? They barely taught us anything about makefiles and I'm completely lost.


Well, I haven't done makefiles in gcc before but it doesn't look this hard...

Personally, I'd do it like that:

CPP=g++
CC=gcc

main: main.o gqueue.o gstack.o
clean:
rm -f main.o gqueue.o gstack.o


From some examples I've been looking at, it seems that gcc (g++) will automatically find the .ccp and .h files and compile them into .o files specified by dependencies in the main target, then it will compile them into output file main. All this based on the implicit rules in the compiler.

The above code is equivalent to:

g++ main.ccp -c
g++ gquque.ccp -c
g++ gstack.ccp -c
g++ main.o gqueue.o gstack.o -o main
rm -f main.o gqueue.o gstack.o
Time is precious. Waste it wisely.
nakam
Profile Joined April 2010
Sweden245 Posts
Last Edited: 2011-05-23 19:57:37
May 23 2011 19:56 GMT
#1082
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?
TL Local Timezone Script - http://www.teamliquid.net/forum/viewmessage.php?topic_id=277156
fiskrens
Profile Joined June 2010
Sweden196 Posts
May 23 2011 20:24 GMT
#1083
select map, player from db where map NOT IN (select map from db where player="Tyler")

shouldn't that do it?
nakam
Profile Joined April 2010
Sweden245 Posts
May 23 2011 20:30 GMT
#1084
On May 24 2011 05:24 fiskrens wrote:
select map, player from db where map NOT IN (select map from db where player="Tyler")

shouldn't that do it?

Thank you! I tested that too and thought that it should work, but I must have made a mistake, because it do work!
TL Local Timezone Script - http://www.teamliquid.net/forum/viewmessage.php?topic_id=277156
Morga
Profile Joined August 2010
Belgium35 Posts
May 23 2011 23:29 GMT
#1085
Hey everyone, just wanted some info I just discovered that black magic is being used in computer science Black magic in cs ! and I was wondering if there are other things like this that are used?
catamorphist
Profile Joined May 2010
United States297 Posts
May 24 2011 05:55 GMT
#1086
On May 24 2011 08:29 Morga wrote:
Hey everyone, just wanted some info I just discovered that black magic is being used in computer science Black magic in cs ! and I was wondering if there are other things like this that are used?


http://hackers-delight.org.ua/
http://us.battle.net/sc2/en/profile/281144/1/catamorphist/
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 24 2011 06:22 GMT
#1087
On May 24 2011 14:55 catamorphist wrote:
Show nested quote +
On May 24 2011 08:29 Morga wrote:
Hey everyone, just wanted some info I just discovered that black magic is being used in computer science Black magic in cs ! and I was wondering if there are other things like this that are used?


http://hackers-delight.org.ua/


One thing to consider for this is that a lot of these tricks (like the above mentioned Inverse Square Root) are for older processors. Newer processors often can do many of the calculations in a single step where older processors needed quite a lot of steps to finish the calculation. The biggest example being floating point calculations that required a lot of time even just 10 years ago and are now sometimes even faster than integer calculations. Even microprocessor programming made a few leaps forward in that regard (though in this field there are still a lot of tricks required for performance).

Also things like alternative implementations to get the length of a string (first 0-byte) are usually already implemented in standard libraries, so unless you write those libraries, you will never find a use for those tricks.

The Inverse Square Root, while at it's time a work of genius, is now superfluous - which is quite sad.
Teton
Profile Joined May 2010
France1656 Posts
May 24 2011 06:35 GMT
#1088
On May 19 2011 14:00 DeCiBle wrote:
I'm trying to append the contents of a string variable to the literal "II##" and assign it to a string in C++, so far I've gone in circles with every kind of temporary variable and conversion type.

basically I'm at:

contains += 1; //update the number of structures within the file
itemID = "II##";
itemID.append(contains.ToString());

but that's obviously not working; every simple solution seems to not exist. Is there any way to convert an interger to a string or put it in a file?

I've tried itemID = "II##" + contains.ToString();

and even just data << contains.ToString(); (where data is an fstream object)

I'm about to go kill. Help.



#include <sstream>

stringstream sstr;
sstr<< "II##" << contains ;
itemid = sstr.str();
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2011-05-24 06:48:41
May 24 2011 06:47 GMT
#1089
On May 24 2011 15:35 Teton wrote:
Show nested quote +
On May 19 2011 14:00 DeCiBle wrote:
I'm trying to append the contents of a string variable to the literal "II##" and assign it to a string in C++, so far I've gone in circles with every kind of temporary variable and conversion type.

basically I'm at:

contains += 1; //update the number of structures within the file
itemID = "II##";
itemID.append(contains.ToString());

but that's obviously not working; every simple solution seems to not exist. Is there any way to convert an interger to a string or put it in a file?

I've tried itemID = "II##" + contains.ToString();

and even just data << contains.ToString(); (where data is an fstream object)

I'm about to go kill. Help.



#include <sstream>

stringstream sstr;
sstr<< "II##" << contains ;
itemid = sstr.str();


Adding explanation to that:
String literals ("||##") are still a klutch in C++, they are actually the classical C character arrays. With emphasis: They are no string objects. For this reason, they also have no overloaded + operator.

(Assuming bar is a string object)
Works:
string foo = bar + "baz";

Doesn't work:
string foo = "baz" + bar;

You either have to convert the string literal (character array) to a string object (i'm quite rusty with C++ syntax, but IIRC something like string foo("bar"); works), or - as in Tetons example - use a stringstream to create the result you want.
Starfox
Profile Joined April 2010
Austria699 Posts
May 24 2011 07:03 GMT
#1090
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?

Did you try something like:
SELECT Map FROM table GROUP BY Map WHERE NOT FIND_IN_SET('Tyler', GROUP_CONCAT(Player) )
or
SELECT t1.Map, t1.Player FROM table t1 WHERE NO EXISTS ( SELECT * FROM table t2 WHERE t1.Map = t2.Map AND t2.Player = 'Tyler' )
Greek Mythology 2.0: Imagine Sisyphos as a man who wants to watch all videos on youtube... and Tityos as one who HAS to watch all of them.
Cube
Profile Blog Joined February 2008
Canada777 Posts
May 24 2011 07:10 GMT
#1091
I'm not sure how I missed this thread (it seems pretty old).

I'm a third year CS student at the University of Calgary, and you can add me to the list of "people willing to help with stuff" if you want.

I can help with C/(rusty)C++, Java, Prolog (intermediate), Haskell, and simple automata / computability / complexity problems.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2011-05-24 07:11:08
May 24 2011 07:10 GMT
#1092
-- ninjaed --
Pkol
Profile Blog Joined April 2010
Australia176 Posts
May 24 2011 07:18 GMT
#1093
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?


I had to do something similar for a project last semester. I used a subquery and a NOT IN function. No idea if it's the most efficient or best way to do it, but it works. I'd guess you'd want to NOT IN a query of the maps Tyler HAS played on.

For reference, my query is below, I had to find out what times a Service Person was available (did not have a prior service call booked).


SELECT * FROM `service_person`
WHERE `service_person_id` NOT IN
(SELECT `service_person_id`
FROM `service_person`
NATURAL JOIN `service_call`
WHERE date = '$date' AND time = '$time')
GROUP BY `service_person_id`


Hope this works :D
lolwut?
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 24 2011 07:35 GMT
#1094
On May 24 2011 16:18 Pkol wrote:
Show nested quote +
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?


I had to do something similar for a project last semester. I used a subquery and a NOT IN function. No idea if it's the most efficient or best way to do it, but it works. I'd guess you'd want to NOT IN a query of the maps Tyler HAS played on.

For reference, my query is below, I had to find out what times a Service Person was available (did not have a prior service call booked).


SELECT * FROM `service_person`
WHERE `service_person_id` NOT IN
(SELECT `service_person_id`
FROM `service_person`
NATURAL JOIN `service_call`
WHERE date = '$date' AND time = '$time')
GROUP BY `service_person_id`


Hope this works :D


NOT EXISTS is usually better as - apart from being easier to read and understand because it's closer to the natural language - the database server can stop as soon as it finds a single entry, for an IN query, it first gathers all results and then checks if it's in the result set.
nakam
Profile Joined April 2010
Sweden245 Posts
Last Edited: 2011-05-24 12:11:31
May 24 2011 12:11 GMT
#1095
On May 24 2011 16:18 Pkol wrote:
Show nested quote +
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?


I had to do something similar for a project last semester. I used a subquery and a NOT IN function. No idea if it's the most efficient or best way to do it, but it works. I'd guess you'd want to NOT IN a query of the maps Tyler HAS played on.

For reference, my query is below, I had to find out what times a Service Person was available (did not have a prior service call booked).


SELECT * FROM `service_person`
WHERE `service_person_id` NOT IN
(SELECT `service_person_id`
FROM `service_person`
NATURAL JOIN `service_call`
WHERE date = '$date' AND time = '$time')
GROUP BY `service_person_id`


Hope this works :D


On May 24 2011 16:03 Starfox wrote:
Show nested quote +
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?

Did you try something like:
SELECT Map FROM table GROUP BY Map WHERE NOT FIND_IN_SET('Tyler', GROUP_CONCAT(Player) )
or
SELECT t1.Map, t1.Player FROM table t1 WHERE NO EXISTS ( SELECT * FROM table t2 WHERE t1.Map = t2.Map AND t2.Player = 'Tyler' )


fiskrens posted a solution that is sufficient enough for me:
select map, player from db where map NOT IN (select map from db where player="Tyler")

If it is the most efficient solution or not I don't know (executing it in 0,03 sec when applied). Thanks for the suggestions though.
TL Local Timezone Script - http://www.teamliquid.net/forum/viewmessage.php?topic_id=277156
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 24 2011 12:16 GMT
#1096
On May 24 2011 21:11 nakam wrote:
Show nested quote +
On May 24 2011 16:18 Pkol wrote:
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?


I had to do something similar for a project last semester. I used a subquery and a NOT IN function. No idea if it's the most efficient or best way to do it, but it works. I'd guess you'd want to NOT IN a query of the maps Tyler HAS played on.

For reference, my query is below, I had to find out what times a Service Person was available (did not have a prior service call booked).


SELECT * FROM `service_person`
WHERE `service_person_id` NOT IN
(SELECT `service_person_id`
FROM `service_person`
NATURAL JOIN `service_call`
WHERE date = '$date' AND time = '$time')
GROUP BY `service_person_id`


Hope this works :D


Show nested quote +
On May 24 2011 16:03 Starfox wrote:
On May 24 2011 04:56 nakam wrote:
I have a problem with a MySQL query:

I want to select a group that does NOT contain a certain value

Table SC2
Map		Player
Desert Oasis Tyler
Desert Oasis Haypro
Desert Oasis TLO
Kulas Extreme Haypro
Blistering TLO

What I want is the following result:
Kulas Extreme	Haypro
Blistering TLO

That is only select the maps Tyler hasn't played on.

I have tried variations of WHERE NOT Player = 'Tyler' and have come to the conclusion that it doesn't work. I think I need to join the table with itself and select the rows where player is NULL somehow, but I can't get it to work. Any ideas?

Did you try something like:
SELECT Map FROM table GROUP BY Map WHERE NOT FIND_IN_SET('Tyler', GROUP_CONCAT(Player) )
or
SELECT t1.Map, t1.Player FROM table t1 WHERE NO EXISTS ( SELECT * FROM table t2 WHERE t1.Map = t2.Map AND t2.Player = 'Tyler' )


fiskrens posted a solution that is sufficient enough for me:
select map, player from db where map NOT IN (select map from db where player="Tyler")

If it is the most efficient solution or not I don't know (executing it in 0,03 sec when applied). Thanks for the suggestions though.


You won't have problems for the next 1000-5000 entries into the table, but after that your performance will decline very quickly.

The suggestion by Starfox should provide the most efficient solution, which is also easier to read (except for the t1/t2 part, i hate it when people name tables t1,t2,t3,... :p)

SELECT t1.Map, t1.Player
FROM table t1
WHERE NOT EXISTS (
SELECT *
FROM table t2
WHERE t1.Map = t2.Map
AND t2.Player = 'Tyler'
)

Teton
Profile Joined May 2010
France1656 Posts
May 24 2011 12:19 GMT
#1097
On May 24 2011 15:47 Morfildur wrote:
Show nested quote +
On May 24 2011 15:35 Teton wrote:
On May 19 2011 14:00 DeCiBle wrote:
I'm trying to append the contents of a string variable to the literal "II##" and assign it to a string in C++, so far I've gone in circles with every kind of temporary variable and conversion type.

basically I'm at:

contains += 1; //update the number of structures within the file
itemID = "II##";
itemID.append(contains.ToString());

but that's obviously not working; every simple solution seems to not exist. Is there any way to convert an interger to a string or put it in a file?

I've tried itemID = "II##" + contains.ToString();

and even just data << contains.ToString(); (where data is an fstream object)

I'm about to go kill. Help.



#include <sstream>

stringstream sstr;
sstr<< "II##" << contains ;
itemid = sstr.str();


Adding explanation to that:
String literals ("||##") are still a klutch in C++, they are actually the classical C character arrays. With emphasis: They are no string objects. For this reason, they also have no overloaded + operator.

(Assuming bar is a string object)
Works:
string foo = bar + "baz";

Doesn't work:
string foo = "baz" + bar;

You either have to convert the string literal (character array) to a string object (i'm quite rusty with C++ syntax, but IIRC something like string foo("bar"); works), or - as in Tetons example - use a stringstream to create the result you want.


but string foo = string("baz") + bar;
should work :p

Seldon
Profile Joined March 2011
90 Posts
Last Edited: 2011-05-24 13:38:14
May 24 2011 12:40 GMT
#1098
On May 19 2011 14:00 DeCiBle wrote:
I'm trying to append the contents of a string variable to the literal "II##" and assign it to a string in C++, so far I've gone in circles with every kind of temporary variable and conversion type.

basically I'm at:

contains += 1; //update the number of structures within the file
itemID = "II##";
itemID.append(contains.ToString());

but that's obviously not working; every simple solution seems to not exist. Is there any way to convert an interger to a string or put it in a file?

I've tried itemID = "II##" + contains.ToString();

and even just data << contains.ToString(); (where data is an fstream object)

I'm about to go kill. Help.


My advice, add this template somewhere in your project.
    
//goes in a .h you include anytime you want to use this function
template<class T> std::string toString(const T& value) {
std::ostringstream oss;
oss << value;
return oss.str();
}



Now you can convert anything to a string without worrying about the order:


resulting_string = toString(1) + toString("ABC") + another_string;
mr_tolkien
Profile Blog Joined June 2010
France8631 Posts
Last Edited: 2011-05-25 00:28:34
May 25 2011 00:23 GMT
#1099
I need help :/ I have some troubles with data structures in Java, and there is something I don't get.

Here is a piece of code from me :
+ Show Spoiler +
HashMap<Position, PositionTree> sons = new HashMap<Position, PositionTree>();

Position a = new Position(0,0);
sons.put(a, null);
Position b = new Position(0,0);
System.out.println(sons.keySet().contains(a));
System.out.println(b.equals(a));
System.out.println(sons.keySet().contains(b));

Position is just a standard class, PositionTree is my tree structure.
When running this I get true true false.
Meaning b.equals(a) is true, sons.keySet() contains a, but... sons.keySet() doesn't "contain" b ?

When looking at the doc of contains ( http://download.oracle.com/javase/1.4.2/docs/api/java/util/Set.html#contains(java.lang.Object) ) it says «returns true if and only if this set contains an element e such that (o==null ? e==null : o.equals(e)). »
It seems to me like it should return true... Does anybody have any clue on what I am doing wrong ?
The legend of Darien lives on
Cloud
Profile Blog Joined November 2004
Sexico5880 Posts
Last Edited: 2011-05-25 01:26:27
May 25 2011 01:12 GMT
#1100
BlueLaguna on West, msg for game.
Prev 1 53 54 55 56 57 1032 Next
Please log in or register to reply.
Live Events Refresh
uThermal 2v2 Circuit
14:00
Season 2 - May 2026
RotterdaM777
uThermal521
mouzHeroMarine434
IndyStarCraft 249
SteadfastSC208
elazer70
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 777
uThermal 562
mouzHeroMarine 434
IndyStarCraft 249
SteadfastSC 208
Railgan 121
elazer 70
StarCraft: Brood War
Britney 27438
Horang2 2111
EffOrt 1509
Shuttle 1475
ggaemo 384
Leta 237
firebathero 182
PianO 154
Dewaltoss 141
Sharp 97
[ Show more ]
actioN 59
ToSsGirL 49
Barracks 39
Pusan 21
Rock 19
Sacsri 18
Terrorterran 15
Dota 2
Gorgc4823
monkeys_forever379
Counter-Strike
fl0m6749
olofmeister2755
Heroes of the Storm
Khaldor359
Liquid`Hasu60
MindelVK8
Other Games
FrodaN1336
Liquid`RaSZi1276
Beastyqt916
B2W.Neo643
KnowMe229
mouzStarbuck192
Grubby87
Organizations
Other Games
gamesdonequick859
BasetradeTV614
Dota 2
PGL Dota 2 - Main Stream72
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• Adnapsc2 18
• Reevou 9
• intothetv
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV753
• lizZardDota284
League of Legends
• Jankos2051
Other Games
• imaqtpie849
• Shiphtur281
Upcoming Events
BSL
1h 4m
IPSL
1h 4m
eOnzErG vs TBD
G5 vs Nesh
Patches Events
6h 4m
Replay Cast
15h 4m
Wardi Open
16h 4m
Afreeca Starleague
16h 4m
Jaedong vs Light
Monday Night Weeklies
22h 4m
Replay Cast
1d 6h
Sparkling Tuna Cup
1d 16h
Afreeca Starleague
1d 16h
Snow vs Flash
[ Show More ]
WardiTV Invitational
1d 17h
SHIN vs Nicoract
Solar vs Nice
GSL
2 days
Classic vs Cure
Maru vs Rogue
GSL
3 days
SHIN vs Zoun
ByuN vs herO
OSC
3 days
OSC
3 days
Replay Cast
4 days
Escore
4 days
The PondCast
4 days
WardiTV Invitational
4 days
Zoun vs Ryung
Lambo vs ShoWTimE
Replay Cast
5 days
CranKy Ducklings
5 days
RSL Revival
5 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
5 days
Krystianer vs TriGGeR
Cure vs Rogue
BSL
6 days
Replay Cast
6 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
6 days
Liquipedia Results

Completed

Proleague 2026-05-02
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
KK 2v2 League Season 1
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W6
BSL 22 Non-Korean Championship
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 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.