In your opinion, when creating a nested loop is it best to use the call function and if so is using a pointer the route to go when creating the function?

Recommended Answers

All 7 Replies

In your opinion, when creating a nested loop is it best to use the call function and if so is using a pointer the route to go when creating the function?

That's like asking when ordering a hamburger is it better to drive a Mustang?

The things in your question don't have a direct relationship.

commented: Sometimes that makes a difference. It depnds on how high-end the place is +4
commented: yeah, i lol'd +8

I'm trying to create a dice game and don’t know if I should call the function or have it all in the main function and if I do have to call it I was curious if pointers are necessary when using strings

If your code is huge then break it into functions
If you have to pass some parameters to the functions, passing them by pointers has an advantage that you can manipulate the value of the string inside the function

Does this answer your question ?If not phrase it differently. As of now its not making any sense at all

commented: not a smart ass! +1

ya. thats the exact answer i was looking for. thanks alot!

Whenever possible, try to avoid nested loop as they have a worst-case of O(n2) - Big O n square. In simple terms, it has bad processing time because your worst case for nested loop is n square iterations. When your n is sufficiently large, your logic will take a very long time to run.

Whenever possible, try to avoid nested loop as they have a worst-case of O(n2) - Big O n square.

the criticism you give is meaningful only for extremely large loops or realtime embedded applications such as scientific instrumentation and measurement.

for small to average sized loops -- the vast majority of cases in a help forum -- the time hit is inconsequential, and nested loops are often the simplest and most direct solution.

He's playing a dice game, for the gods' sake. we don't need a junior-level CSC optimization lecture. :icon_rolleyes:

commented: I cried when I read this, even a little wee came out. +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.