Char To String & Then Array.
-
I am currently taking data from a database that is in the form of char data and attempting to convert to a string and then saving in a char array. It appears that these strings have to be saved in a two dimension array. The first array or inner array containing each element of the date in the form of chars. The outer array then contains each record or occurance of the date. Can someone help me in copying the string data into the array? Listed below is what I have so far.
char Date1[10] = {};
vFieldDate = rec->Fields->GetItem("Date")->Value;for(int r = 0; r < 1; r++)
{
for(int c = 0; c < 10; c++)
{
strcpy (Date1,vFieldDate);
strcpy (Date[r][c],Date1[10]);
printf ("%s",Date[r][c]);
}
} -
I am currently taking data from a database that is in the form of char data and attempting to convert to a string and then saving in a char array. It appears that these strings have to be saved in a two dimension array. The first array or inner array containing each element of the date in the form of chars. The outer array then contains each record or occurance of the date. Can someone help me in copying the string data into the array? Listed below is what I have so far.
char Date1[10] = {};
vFieldDate = rec->Fields->GetItem("Date")->Value;for(int r = 0; r < 1; r++)
{
for(int c = 0; c < 10; c++)
{
strcpy (Date1,vFieldDate);
strcpy (Date[r][c],Date1[10]);
printf ("%s",Date[r][c]);
}
} -
I am currently taking data from a database that is in the form of char data and attempting to convert to a string and then saving in a char array. It appears that these strings have to be saved in a two dimension array. The first array or inner array containing each element of the date in the form of chars. The outer array then contains each record or occurance of the date. Can someone help me in copying the string data into the array? Listed below is what I have so far.
char Date1[10] = {};
vFieldDate = rec->Fields->GetItem("Date")->Value;for(int r = 0; r < 1; r++)
{
for(int c = 0; c < 10; c++)
{
strcpy (Date1,vFieldDate);
strcpy (Date[r][c],Date1[10]);
printf ("%s",Date[r][c]);
}
}Through research the following was derived from an MSDN website:
#define ARR 65500 //Total Records
#define TARGSIZE 11 //Field Lengthchar Date[ARR][TARGSIZE] = {};
orig = rec->Fields->GetItem("Time")->Value; //ADO Data
// Convert to a char*
const size_t newsize = 100;
char nstring[newsize];
strcpy_s(nstring, (char *)orig); //Typecast & Copy Data Elements
strncpy(Date[cyc],nstring,TARGSIZE - 1);//Copy String To Array
printf("%s",nstring);
printf("\n");Original MSDN website: http://msdn.microsoft.com/en-us/library/ms235631(v=vs.80).aspx[^]
-
Through research the following was derived from an MSDN website:
#define ARR 65500 //Total Records
#define TARGSIZE 11 //Field Lengthchar Date[ARR][TARGSIZE] = {};
orig = rec->Fields->GetItem("Time")->Value; //ADO Data
// Convert to a char*
const size_t newsize = 100;
char nstring[newsize];
strcpy_s(nstring, (char *)orig); //Typecast & Copy Data Elements
strncpy(Date[cyc],nstring,TARGSIZE - 1);//Copy String To Array
printf("%s",nstring);
printf("\n");Original MSDN website: http://msdn.microsoft.com/en-us/library/ms235631(v=vs.80).aspx[^]