I have 8.5 million combinations which are then put through 30 if statements.

Then final output.

Now I havent tried this yet BUT I dont think php will let me make a 8.5 million length array nor will C++.

So what else can I do?

Are there any other lanuages out there?

Any other way to do it?

Thanks, Regards X

PS: Best programming language is C++, correct?

>>Now I havent tried this yet BUT I dont think php will let me make a 8.5 million length array nor will C++.

Depends on the C++ compiler -- most (all) 32-bit compilers will do it but no 16-bit compiler such as Turbo C. An array of 8.5 million integers consumes 8500000 * sizeof(int) = 34,000,000 bytes, or roughly 32 meg.

>>PS: Best programming language is C++, correct?
depends on what you want to do. assembly might be the best for some solutions.

Member Avatar for iamthwee

There might be another alternative although, not guaranteed to find the optimal solution.

Have you thought about dynamic programming.

Sorry guys im new to C++ (havent used it since university).

I usually program in php, hence the solution in php.

But im running into alot of memory issues with making arrays, run out of memory, etc.

So can you point in the direction of software I can use for C/C++?

Dynamic programming - dont know what it is?

If C++ can:
- make a 8.5million long array
- add/remove arrays from the 8.5million
- break up array string into single variables
- simple if statements

Now I can do all the above in php so I gather it can be done in C since it was the foundation for all programing, just wanted to confirm everything before I start learning C again, lol.

Thanks, Regards X

PS: C vs. C++ whats difference? what should I use?

>> PS: C vs. C++ whats difference?

see these google links.

>>what should I use?
Its up to you, but I would use c++ because you can use c++ container classes like vector that does all the dynamic memory allocation for you. You can easily add, subtract, and sort vector array elements without worrying about how to do it.

But I suspect you need to rethink what you want to do. 8.5 million array elements is very unusual. Do you really need an array that huge? Is there another way to do what you want without that large an array?

Well I have 8 million different combinations which then need to be put through if statements.

If you can suggest a better way, I would be glad to hear it.

Problem I have is alot of calculations that MUST be done on alot of numbers :(

But what I described is it all possible to do in C++ because I dont want to spend all my time and effort in learning C++ and doing the program and then not being able to do it.

If C++ can:
- make a 8.5million long array
- add/remove arrays from the 8.5million
- break up array string into single variables
- simple if statements

Sorry about the really newbie questions :(

Thanks Again, Regards X

you have 8.5 million array of what type? integers, floats, strings, or what. You have to declare the data type when you declare the array in c/c++.

How do you get the data for that array? Read the number from a data file, get them from SQL database, or something else?

Without knowing exactly what you are attempting to do I can't give you much more help or suggestions.

Ok I have a bunch of for loops that in turn produce the 8 million array.

Each array just contains different combinations of numbers taken from the for loops.

Eg. 1 2 3 4 5 6

I want to be able to break that string up to compare the variables (1 vs. 2, 2 vs. 3, etc) and then depending remove that array.

Is that a better explaniation?

Anymore questions, just ask.

Thanks for all the help, Regards X

I think you didn't provide enough information about your project. For example: how the loop produce the combination? how will you compare those combination? what is the purpose of your combination? what is the pattern of your combination? and what type of combination that need to be romoved? I suggest you should describe your project in more detail and about the purpose of your project and what will your program do?

commented: Good Questions! +1

I want to do the project myself I do not want someone else to do my work for me and in turn there all unrelated questions being too specific and would waste the person's time and my own - like I said I havent even designed it yet, I only have ideas from php (this dosent have to be an online project).

Im just wanting to know the program I am wanting to do is viable in C++ (possible url to C++ statistics page).

C++ functions allow:
- 8.5million long array
- add/remove arrays from the 8.5million
- break up arrays into single variables
- simple if statements

Like I said I can do all the above in php but it freezes due to lack of memory when creating the 8.5 million array.

So can anyone tell me if the above is possible in C++? Thankyou.

>> 8.5million long array
I already answered that -- and the answer is yes.

>>add/remove arrays from the 8.5million
Easy to do with vector class, but it might be a little slow because of the magnitude of the array. Maybe std::list (a linked list) would be more suitable because the insertion and deletion time is constant while vector is not constant.

>>break up arrays into single variables
If you use a vector<int> then you don't need to do the above because they're already individual variables.

Here the proof that it works in c++: Compile and run this with your c++ 32-bit compiler to see for yourself.

#include <iostream>
#include <vector>
using namespace std;

int main()
{
    const int maxsize = 8500000;
   vector<int> lst;
   lst.resize(maxsize);
   for(int i = 0; i < maxsize; i++)
       lst[i] = i;
   cout << "done\n";
    cin.get();
}
commented: Thankyou for the help and information +1

Nice!!!

Thanks.

Ok I will get to work on it.

I am planning to use the new Borland C++ 5.1 I think and well see how it goes.

Thanks for the help, Regards X

Nice!!!

I am planning to use the new Borland C++ 5.1 I think and well see how it goes.

New??? OMG that compiler is ancient and only supports 16-bit MS-DOS 6.X and earlier. Get a good new compiler, such as VC++ 2008 Express (free) or Dev-C++ (also free).

I am using:
Borland C++ 5.02 for Windows

The two you mentioned:
Do you have a urls for them?

Thanks, Regards X

Not with Borland C++ 5.1 I you didn't. :)

From the previous link:

Borland C++ 5.0 - (1996, Windows 95) Released in March 1996. Works on Windows 95 and Windows NT 3.51. It does not (officially) work on Windows NT 4.0 (which was still in development at that time). 3rd party tests exhibited some problems on NT 4.0. It does not work in Windows 3.x or DOS. Despite that, it can produce either Win32, Win16 or DOS programs.

Also,

In January 1994 Borland launched Borland C++ 4.0 for Windows which also included OWL 2.0. It added Doc/View support, VBX controls, OLE. Win16, Win32s and Win32 was supported (Windows 95, the Win32 successor of Windows 3.x appeared in August 1995).

VC++ 2008 Express

Dev-C++

Codea::Blocks

There all just C++ compilers, correct?

I just downloaded them.

Which one is the best?

I have Boreland installed at the moment will that do the job for now as optimal (speed wise)?

Thanks, Regards X

PS: Dont forget im running programs that take hours as well. Thankyou.

There all just C++ compilers, correct?

No. They are all IDE's (Integrated Development Environments). The compiler is just a part of it.

Which one is the best?

I personally like VC++, it has a lot of very handy features.
But the other two programs have a smaller footprint and if your computer isn't very new anymore, you might want to choose from code::blocks and devc++. I can't tell which of these 2 is better, because I haven't used them for the last few years :)

I have Boreland installed at the moment will that do the job for now as optimal (speed wise)?

Please, just remove it from your HD and learn to work with a program (and compiler) that is up-to-date instead of 10 years old

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.