•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 397,855 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,380 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 637 | Replies: 10
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,644
Reputation:
Rep Power: 36
Solved Threads: 867
First you have to find out how many comma-separated words are in the string. Iterate through the string and count the commans. Then allocate the int array large enough to hold that many integers. After that, go through the string agsin, this time when you find a comma set one of the integers to be the numeric value of where the comma was found.
For example in the string you posted you will need three integers because the string contains three comma-separated words. The first integer will be 0, the second integer 4 and the 3d integer is 9.
For example in the string you posted you will need three integers because the string contains three comma-separated words. The first integer will be 0, the second integer 4 and the 3d integer is 9.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,644
Reputation:
Rep Power: 36
Solved Threads: 867
>>how do i allocate it to the size i want
This is c++ so use the new operator to allocate the array
This is c++ so use the new operator to allocate the array
m_starts = new int[NumberOfIntegers]; I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
Join Date: Dec 2007
Location: Port Dickson, Malaysia
Posts: 37
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,644
Reputation:
Rep Power: 36
Solved Threads: 867
•
•
•
•
But I though DMA is for integers contain in an array only? Characters won't work for DMA....I've tried it before
Huh? I assume DMA means Direct Memory Address. How does that relate to the discussion of this thread ? BTW DMA is not possible with any 32-bit compiler unless writing a kernel-mode device driver.
Last edited by Ancient Dragon : Dec 18th, 2007 at 9:09 am.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
•
•
Huh? I assume DMA means Direct Memory Address. How does that relate to the discussion of this thread ? BTW DMA is not possible with any 32-bit compiler unless writing a kernel-mode device driver.
I think he means 'Dynamic Memory Allocation' - I could be wrong though. Either way, it works fine with both char and int
Last edited by Bench : Dec 18th, 2007 at 10:20 am.
¿umop apisdn upside down? ![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
Similar Threads
- convert int to string (C)
- turning and int into seperate digits (C++)
- variable function parameters functionname(int a, ...) (C)
Other Threads in the C++ Forum
- Previous Thread: Program help
- Next Thread: No output

.

Linear Mode