Hi guys,
Please can someone explain me how would I split a string into groups.
In other words, I have a string of numbers, as such:

123456789
I am supposed to store them in linked list nodes as such:
node 1: 1
node 2: 2345
node 3: 6789

I was thinking to do something like get the length of the string.
In this case: 9
Divide by 2 and store in variable div ( in this case div = 4)
Then mod length/2 and store in var mod( in this case mod = 1)
Then I am stuck thinking how would I store in to nodes 1, 2, 3 accordingly.

Would really appreciate any help.
Thanks.

In this specific case you could use two loops. One to get the number of elements indicated by length %2 and the other to however many groups of length/2 elements there are.

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.