C程序中的“数组下标不是整数”

时间:2017-05-22 02:08:34

标签: c arrays multidimensional-array char

void imprimirTablero(char *tablero[7][7], int *posicionX, int *posicionY)
{
    int i, j;
    tablero[posicionX][posicionY] = 'R';
    for(i = 0; i < LEN(tablero); i++)
    {
        for(j = 0; j < LEN(tablero[0]); j++)
        {
            printf(tablero[i][j]);
        }
    }
}

这个方法改变了positionX,positionY中的char并打印了新的字符矩阵....请有人帮帮我

2 个答案:

答案 0 :(得分:1)

您使用指向整数的指针作为posicionXposicionY的数组索引。你需要取消引用这些指针:

tablero[*posicionX][*posicionY] = 'R';

答案 1 :(得分:1)

你传递的是指针的二维数组,而不是字符,以及两个指向整数的指针,而不是整数。我想你想要:

     HttpStatusCode status;

                using (var client = new HttpClient())
                {
                    client.Timeout = TimeSpan.FromSeconds(10); // candidate for .config setting
                                                               // client.DefaultRequestHeaders.Add("User-Agent", USER_AGENT);

                    //here I use my blob file to test it              
                    var request = new HttpRequestMessage(HttpMethod.Get, "https://xxxxxxxxxx.blob.core.windows.net/media/secondblobtest-eypt.txt");
                    var sendTask =  client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
                    var response = sendTask.Result; // not ensuring success here, going to handle error codes without exceptions
                    status = response.StatusCode;

                    if (status == HttpStatusCode.OK)
                    {
                        MemoryStream ms = new MemoryStream();

                        var httpStream = response.Content.ReadAsStreamAsync().Result;

                        httpStream.CopyTo(ms);
                        ms.Position = 0;
                       WriteFile("aaa", "testaa", ms);
                     //   hash = HashGenerator.GetMD5HashFromStream(httpStream);
                    }
                }

判断

void imprimirTablero(char tablero[7][7], int posicionX, int posicionY)