•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,553 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 3,493 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: Programming Forums
Views: 705 | Replies: 5
![]() |
| |
•
•
Join Date: Oct 2007
Posts: 28
Reputation:
Rep Power: 2
Solved Threads: 0
I'm having problem with storing values in multi dimensional arrays. I need to have 10 * 10 array with rows and columns. I have intitialized the array with blank spaces " ". But after this I need to store letters like 'A' 'C' 'S' on specific locations in that array.
for example
0 1 2 3 4 5 6 7 8 9
0
------------------------------------------
1
-------------------------------------------
3
--------------------------------------------
4
--------------------------------------------
5
------------------------------------------
6
-------------------------------------------
7
-------------------------------------------
8
--------------------------------------------
9
--------------------------------------------
First question, do I print this layout board using for loop?
Second, that how would i put character 'A' in location Row = 0 and Column = 5???
and then display it
I know these questions are really basic but I'm just a beginner.
Thanks
for example
0 1 2 3 4 5 6 7 8 9
0
------------------------------------------
1
-------------------------------------------
3
--------------------------------------------
4
--------------------------------------------
5
------------------------------------------
6
-------------------------------------------
7
-------------------------------------------
8
--------------------------------------------
9
--------------------------------------------
First question, do I print this layout board using for loop?
Second, that how would i put character 'A' in location Row = 0 and Column = 5???
and then display it
I know these questions are really basic but I'm just a beginner.
Thanks
You can traverse a two-dimensional array with a nested loop:
>Second, that how would i put character 'A' in location Row = 0 and Column = 5???
Assuming it's a two-dimensional array of char or int:
for ( i = 0; i < 10; i++ ) {
for ( j = 0; j < 10; j++ )
printf ( "%c ", array[i][j] );
}Assuming it's a two-dimensional array of char or int:
array[0][5] = 'A';
I'm here to prove you wrong.
•
•
Join Date: Oct 2007
Posts: 28
Reputation:
Rep Power: 2
Solved Threads: 0
for ( i = 0; i < 10; i++ ) {
for ( j = 0; j < 10; j++ )
printf ( "%c ", array[i][j] );
}Thanks for your help though.
>Is this the initializing process?
No, that would allow you to print every element of a multi-dimensional array of 10 by 10.
But you can use the same construct of two for loops to assign values to each element.
No, that would allow you to print every element of a multi-dimensional array of 10 by 10.
But you can use the same construct of two for loops to assign values to each element.
At the very moment that I find myself in the side of the mayority, I will know that I need to re-think my ideas. ~ In my book.
•
•
Join Date: Oct 2007
Posts: 28
Reputation:
Rep Power: 2
Solved Threads: 0
Oh, ok. Thanks
Another question I would like to ask is that...assuming I have stored specific values in the 10*10 array, and I want the user to guess their locations on the array until he runs out of given tries////how can I do that?
Should I use while loop for tries?
But I would like some hint how to put user provided rows and column and compare it with values on my 10*10array?
I would appreciate some help.
Another question I would like to ask is that...assuming I have stored specific values in the 10*10 array, and I want the user to guess their locations on the array until he runs out of given tries////how can I do that?
Should I use while loop for tries?
But I would like some hint how to put user provided rows and column and compare it with values on my 10*10array?
I would appreciate some help.
Last edited by Sh13 : Oct 17th, 2007 at 8:43 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- typedef or a multidimensional array? (C)
- Multidimensional array sort problem (C++)
- Question regarding multidimensional array for navigation bar (Graphics and Multimedia)
- Sort multidimensional array on more than one column? (ASP)
- multidimensional array merge using PHP (PHP)
- How to Sort a MultiDimensional Array (C)
- multidimensional array (C)
Other Threads in the C Forum
- Previous Thread: Scanf vs fgets
- Next Thread: Beware writing code without a plan



Hybrid Mode