|
You actually understood his query? Man you're too good.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: You actually understood his query?
I try my best guessing about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: I try my best guessing about.
I got that now.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Eranga Thennakoon wrote:
How can I send those values to the addData() function using two functions as shown above.
You can't. The two functions you've shown have no way of sending data back to the caller. If you are allowed to change them, something like:
string getName( void )
{
}
char getGender( void )
{
}
...
addData(getName(), getGender()); might work.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
how to show Menubar on the DialogBOX resource and use it
in both plain sdk or MFC
Trioum
|
|
|
|
|
SetMenu( HMENU ) works.
Greetings from Germany
|
|
|
|
|
Use LoadMenu API or CMenu::LoadMenu
then use SetMenu API or CMenu::SetMenu
|
|
|
|
|
how can use ATL CImage class with out using MFC (with plain win 32API).
whether I have to ship any dll (or .net frame work)with my project binary . I am using visual studio 2005 with unmanaged c++
|
|
|
|
|
|
dear all
if now i have a array which contains 10 values, for example, kelly[10],how to save this array as a txt file or other extension file. thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
You may use:
(1) a text format for a human readable file.
(2) a binary format for later retrieval of array values.
Regarding the API , you have a lot of options: the std::ofstream class methods or standard C functions (fopen, fwrite, fclose ), the Win32 API (like CreateFile, WriteFile, CloseHandle functions) or the MFC classes (like CFile , CStdioFile ), ...
Moreover, I think it is time (considering all your previous posts) to have a look at MFC serialization [^] topic.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
dear friend
how to understand the following code:
ofs.write( (char*)&count, sizeof(count));that means char*;
how to save using std::ofstream? thanks a lot,...urgent..
second question is that can you provide me the stuff: for example: %d,if%, and so forth..i read them before, but so far i couldn't find these matierials, thanks a lot.
Li Zhiyuan
5/10/2006
|
|
|
|
|
To write some data to the file, the ostream object needs to know
(1) the address of the data.
(2) the size of the data.
(1) Well, &count means exactly the address of the variable count (as int pointer) and (char *) is a cast of the int pointer to a char one (ostream works on byte basis and it requires a char pointer, a char is 1-byte long, after all...).
(2) sizeof(count) is the size of count , i.e. the size of an integer variable (i.e. 4 bytes).
li zhiyuan wrote: second question is that can you provide me the stuff: for example: %d,if%, and so forth
%d, %f are format specifiers for the printf (as well for fprintf , fscanf functions): whenever you need to print a particular type using such function(s) then you have to use the proper format specifier, for instance
int i= 100;
float f = 3.14159;
printf("An integer, i=%d, a float f=%f\n", i, f);
Full documentation can be found here http://msdn2.microsoft.com/en-us/library/hf4y5e3w(VS.71).aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
dear friend
thank u very much.
how to create 10 3x4 arrays, late when i wanna use anyone of them, i can invoke it, i tried two days already, could not solve this problem,..really urgent now...thanks a lot..
how can i find full explanation of format specifier: &d,%1f........i need to read recall them..forgot it already..thanks a lot
Li Zhiyuan
5/10/2006
|
|
|
|
|
Actually, in a previous reply, I showed exactly all the necessary steps, using ofstream and ifstream , to perform the task on a simple array. I think you can easily figure out how to extend the posted code to fulfill your needs.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
dear friend
where can i find ofs.write() and ofs.read() function explanation? thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
|
dear brother
i tried many times i still couldn't finish this point, could you help me to provide detail of this. how to write 10 3x4 random value arrays, thanks a lot..i am really worried now.....i couldn't extend from your previious code
Li Zhiyuan
5/10/2006
|
|
|
|
|
But do you need to write in a human readable format (i.e. such that you could later open the file with the Notepad and see the numbers) or you need just to store the numbers for later retrieval (and re-construction of the array)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
no need, just create 10 3x4 arrays, and in later my program, i need to use anyone of them...that is all, thanks
Li Zhiyuan
5/10/2006
|
|
|
|
|
If I remember well, you have arrays of doubles.
I give you a really crude sample code working.
(1) Create 10 3x4 arrays, initialise them with random values, i.e.
int i, j, k;
double a[10][3][4];
for (i=0; i<10; i++)
for (j=0; j<3; j++)
for (k=0; k<4; k++)
a[i][j][k] = (double)rand()/RAND_MAX;
(2) Store all of the elements of all the arrays inside a file, explicitely
exploiting our knowledge of array size (really poorly coding, indeed).
FILE * fp = fopen("arrays.bin","wb");
fwrite(a, sizeof(double), 10 * 3 * 4, fp);
fclose(fp);
(3) Retrieve all of the array values from file content to buil the new 10 3x4 arrays.
double b[10][3][4];
FILE * fp = fopen("arrays.bin","rb");
fread(b, sizeof(double), 10 * 3 * 4, fp);
fclose(fp);
(3) bis, retrieve the 7-th array from the file content
double c[3][4];
FILE * fp = fopen("arrays.bin","rb");
fseek(fp, sizeof(double) * 6 * 4 * 3, SEEK_SET);
fread(c, sizeof(double), 3 * 4, fp);
fclose(fp);
hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
thanks a lot brother, how can i see a[5][3][4] array?
int i, j, k;
double a[10][3][4];
for (i=0; i<10; i++)
{
for (j=0; j<3; j++)
{
for (k=0; k<4; k++)
a[i][j][k] = (double)rand()/RAND_MAX;
cout <<" "<<a[i][j][0]<<" "<<a[i][j][1]<<" "<<a[i][j][2]<<" "<<a[i][j][3];
cout << endl;
}
}
but however i couldn't get solution, for example,
a[5]
display 3x4 array
like this.
Li Zhiyuan
5/10/2006
|
|
|
|
|
li zhiyuan wrote: how can i see a[5][3][4] array?
please elaborate.
li zhiyuan wrote: int i, j, k;
double a[10][3][4];
for (i=0; i<10; i++)
{
for (j=0; j<3; j++)
{
for (k=0; k<4; k++)
a[i][j][k] = (double)rand()/RAND_MAX;
cout <<" "<<a[i][j][0]<<" "<<a[i][j][1]<<" "<<a[i][j][2]<<" "<<a[i][j][3];
cout << endl;
}
}
but however i couldn't get solution, for example,
a[5]
display 3x4 array
Your code displays all of the a elements. What do you need instead?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
li zhiyuan wrote: how to create 10 3x4 arrays...
Creating arrays and printing them are two different things. Which one is troubling you?
li zhiyuan wrote: how can i find full explanation of format specifier: &d,%1f........i need to read recall them..forgot it already..thanks a lot
CPallini already provided you with a link. Did you not consult it?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
With std::transform , how to transform the stream buffer of an std::fstream object to lower case? Thanks!
The below code gets error C2248.
std::fstream file("data.txt", std::ios::in);
std::istream_iterator<std::fstream> p(file);
std::istream_iterator<std::fstream> pE;
std::transform(p, pE, p, ::tolower);
Maxwell Chen
|
|
|
|
|