Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 483 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I Need Help With This Vector Problem

#11
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?
Reply

#12
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?
Reply

#13
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
Reply

#14
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.

Reply

#15
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?
Reply

#16
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.

Reply

#17
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.
Reply

#18
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.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through