Thread: Need help with 2 deminsional string.

  1. #1
    Registered User
    Join Date
    Dec 2011

    Need help with 2 deminsional string.

    my string is char loc[3][3];
    i need help setting every variable to a space

  2. #2
    Registered User
    Join Date
    Sep 2006
    A space char is ascii 32 on most PC's. If you don't have an ascii table yet, you can easily download one from the net. Very handy for anyone who programs.

    If you mean a null char, then it's just '\0'. For both the form in general is
    for(row=0;row<R;row++) {//R=3 in your example
       for(col=0;col<C;col++) { //C=3  "   "      "
            and assign your char array[row][col] the value of either '\0' or 32

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    No, don't go using magic numbers like 32. The only time you ever need an ASCII table is when debugging and looking at stuff in a memory viewer. If you're actually writing code then you should always be using actual characters.
    In this case a space was asked for, so that means assigning a space character, e.g.
    loc[i][j] = ' ';
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 22
    Last Post: 07-28-2011, 01:26 PM
  2. Replies: 7
    Last Post: 06-16-2011, 06:21 PM
  3. Implement an N deminsional mathematical vector.
    By User Name: in forum C++ Programming
    Replies: 8
    Last Post: 05-16-2011, 01:25 PM
  4. Replies: 5
    Last Post: 05-09-2010, 10:58 AM
  5. Replies: 1
    Last Post: 10-31-2005, 11:36 AM