|
PQgetvalue()関数だとか、PGresult だとか言われても、仕様不明なので
回答できません。せめて、コードテスト可能なレベルまで問題を落としこんで
くれないと、回答のしようがありません。
ってことで、勝手に適当な同じ名前のオブジェクトと関数を定義してやってみた
サンプル。Windows2000sp4/VC++6.0sp6/Console-Appで動作確認済。
#include <stdio.h>
#include <string.h>
enum{ BUF_SIZE = 20 };
typedef struct PGresult_
{
char value[BUF_SIZE][BUF_SIZE];
} PGresult;
const char *PQgetvalue(PGresult *res, int i, int j)
{
static char buff[BUF_SIZE];
memset(buff, 0, BUF_SIZE);
strcpy(buff, &res->value[i][j]);
return buff;
}
int main()
{
PGresult result = { "test string", "test string2" };
PGresult *res = &result;
char copy_value[BUF_SIZE][BUF_SIZE][BUF_SIZE] = {0};
const char *table = NULL;
int i, j;
for(i = 0; i < 2; i++){
for(j = 0; j < 10; j++){
// 一文でかけるけど分けてみた。これでコピーはできるが?
table = PQgetvalue(res, i, j);
strcpy(copy_value[i][j], table);
}
}
for(i = 0; i < 2; i++){
for(j = 0; j < 10; j++){
// 出力して確認してみなされ
printf("copy_value[%d][%d] = \'%s\'\n", i, j, copy_value[i][j]);
}
}
return 0;
}
|