Posts: 0
Threads: 0
Joined: Mar 2020
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(08-08-2019, 04:47 PM)Drako Wrote: [To see links please register here]
Quote: (08-08-2019, 04:02 AM)phyrrus9 Wrote: [To see links please register here]
Quote: (08-07-2019, 08:02 PM)Drako Wrote: [To see links please register here] I started doing that a while back when I read that endl was actually inefficient. What I read, and also heard from a lot of people was that it flushes and creates a newline. Which is unnecessary.
You'd be correct on it being inefficient, but the entirety of cout is that way. As for flushing the stream though, that's what std::flush is for.
I had already built the entire program with cout so I didn't want to try and use printf. Printf is a lot faster. As for my problem, any solutions?
which problem was that?
|
Posts: 0
Threads: 0
Joined: Mar 2019
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(08-09-2019, 07:20 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (08-08-2019, 04:47 PM)Drako Wrote: [To see links please register here]
Quote: (08-08-2019, 04:02 AM)phyrrus9 Wrote: [To see links please register here] You'd be correct on it being inefficient, but the entirety of cout is that way. As for flushing the stream though, that's what std::flush is for.
I had already built the entire program with cout so I didn't want to try and use printf. Printf is a lot faster. As for my problem, any solutions?
which problem was that?
My reply there. Do you at least have an idea on how I can solve it?
|
Posts: 0
Threads: 0
Joined: Oct 2018
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(08-09-2019, 10:38 PM)Drako Wrote: [To see links please register here]
Quote: (08-09-2019, 07:20 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (08-08-2019, 04:47 PM)Drako Wrote: [To see links please register here] I had already built the entire program with cout so I didn't want to try and use printf. Printf is a lot faster. As for my problem, any solutions?
which problem was that?
My reply there. Do you at least have an idea on how I can solve it?
Of using cout instead of printf? If it's not a real problem, I wouldn't worry about it. Going forward, if you can stand your codebase being unclean, use printf for new stuff. I was merely curious why you mixed the two
|
Posts: 0
Threads: 0
Joined: Dec 2020
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(08-09-2019, 11:04 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (08-09-2019, 10:38 PM)Drako Wrote: [To see links please register here]
Quote: (08-09-2019, 07:20 PM)phyrrus9 Wrote: [To see links please register here] which problem was that?
My reply there. Do you at least have an idea on how I can solve it?
Of using cout instead of printf? If it's not a real problem, I wouldn't worry about it. Going forward, if you can stand your codebase being unclean, use printf for new stuff. I was merely curious why you mixed the two
I quoted the wrong post...
I meant my code, and not cout and printf.
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
|
Posts: 0
Threads: 0
Joined: Jan 2023
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(08-09-2019, 11:04 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (08-09-2019, 10:38 PM)Drako Wrote: [To see links please register here]
Quote: (08-09-2019, 07:20 PM)phyrrus9 Wrote: [To see links please register here] which problem was that?
My reply there. Do you at least have an idea on how I can solve it?
Of using cout instead of printf? If it's not a real problem, I wouldn't worry about it. Going forward, if you can stand your codebase being unclean, use printf for new stuff. I was merely curious why you mixed the two
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
I've changed a lot of the code. What I need to know now is how to save the elements in the vector after they have been shuffled. I need to know this because all of the code you see above is in a 'void' function. So once the 'void' function is called, everything in my vector is reset. Is there a way I can save the elements to memory?
|
Posts: 0
Threads: 0
Joined: Apr 2020
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(10-14-2019, 07:02 PM)Drako Wrote: [To see links please register here]
Quote: (08-09-2019, 11:04 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (08-09-2019, 10:38 PM)Drako Wrote: [To see links please register here] My reply there. Do you at least have an idea on how I can solve it?
Of using cout instead of printf? If it's not a real problem, I wouldn't worry about it. Going forward, if you can stand your codebase being unclean, use printf for new stuff. I was merely curious why you mixed the two
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
I've changed a lot of the code. What I need to know now is how to save the elements in the vector after they have been shuffled. I need to know this because all of the code you see above is in a 'void' function. So once the 'void' function is called, everything in my vector is reset. Is there a way I can save the elements to memory?
Pass the vector by reference.
change
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
to
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
and then get the begin and end iterators from within the function.
Oh, and of course, change your call to
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
|
Posts: 0
Threads: 0
Joined: Oct 2017
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(10-14-2019, 07:56 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (10-14-2019, 07:02 PM)Drako Wrote: [To see links please register here]
Quote: (08-09-2019, 11:04 PM)phyrrus9 Wrote: [To see links please register here] Of using cout instead of printf? If it's not a real problem, I wouldn't worry about it. Going forward, if you can stand your codebase being unclean, use printf for new stuff. I was merely curious why you mixed the two
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
I've changed a lot of the code. What I need to know now is how to save the elements in the vector after they have been shuffled. I need to know this because all of the code you see above is in a 'void' function. So once the 'void' function is called, everything in my vector is reset. Is there a way I can save the elements to memory?
Pass the vector by reference.
change
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
to
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
and then get the begin and end iterators from within the function.
Oh, and of course, change your call to
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
I feel genuinely stupid. I fixed my problem based a bit off of your answer. All I needed to do was declare the 'infectChance' vector outside of my void function. I guess I was trying to over complicate things. Thanks for your reply! I've been trying to fix this for about a month.
|
Posts: 0
Threads: 0
Joined: Jun 2023
Reputation:
0
Level: inf []
Total Points: inf
Rank nan / 1
100% to upload Level
Activity inf / 1
99% to upload your Rank
Experience nan
100% to upload Experience
Points: 50
|
Quote:(10-15-2019, 04:47 AM)Drako Wrote: [To see links please register here]
Quote: (10-14-2019, 07:56 PM)phyrrus9 Wrote: [To see links please register here]
Quote: (10-14-2019, 07:02 PM)Drako Wrote: [To see links please register here]
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
I've changed a lot of the code. What I need to know now is how to save the elements in the vector after they have been shuffled. I need to know this because all of the code you see above is in a 'void' function. So once the 'void' function is called, everything in my vector is reset. Is there a way I can save the elements to memory?
Pass the vector by reference.
change
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
to
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
and then get the begin and end iterators from within the function.
Oh, and of course, change your call to
Hidden Content
You must [To see links please register here] or [To see links please register here] to view this content.
I feel genuinely stupid. I fixed my problem based a bit off of your answer. All I needed to do was declare the 'infectChance' vector outside of my void function. I guess I was trying to over complicate things. Thanks for your reply! I've been trying to fix this for about a month.
No.....you didn't fix your problem, you made it worse. You shouldn't have any global variables. Pass them back and forth between your functions, this isn't Python.
|
|