Thread: Variables within strings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2015
    Posts
    52

    Variables within strings

    Hello everyone!

    I'm a beginner with C, having learned some basics in a university course, but I want to get better at programming. It's also my first post here :3

    Now, on to my question.

    I have created a 2d char array which I want to fill by using for functions. They should all have values in the form of "i,j", where i and j are the coordinates of each string in the array (i.e. the first element of the first line should have a value of 1,1).
    However, I can't figure out how to make the i and j in the value assignment variable. So, I'm stuck with
    Code:
    for(i=1; i<=SIZE; i++)
            for(j=1; j<=SIZE; j++)
                map[i][j]="i,j";
    but I don't know what to do to make the last i and j variable, so every element just gets the value "i,j" instead of the correct numbers.

    Thanks in advance for any help!
    EDIT: I'd also like to be able to read the values I give to each element, aka its coordinates.
    Last edited by Sotos; 05-28-2015 at 10:14 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assigning variables to strings
    By FlyingIsFun1217 in forum C++ Programming
    Replies: 3
    Last Post: 10-20-2006, 06:39 PM
  2. variables and strings with WinExec
    By y_notm in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 02:41 PM
  3. Variables, Strings
    By BenH in forum C++ Programming
    Replies: 3
    Last Post: 05-16-2002, 10:02 PM
  4. Variables TO Strings
    By Okiesmokie in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 11:06 PM
  5. turning variables into strings
    By jagerhans in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2001, 02:10 PM