|
The he should move the request to QA: we have the MysticalPowers tag there.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: The he should move the request to QA: we have the MysticalPowers tag there
he hehe good one!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hasani2007 wrote: 1-a program to get countries and then print the capital of them.
Please give me an example.
2-multiplication of two arrays.(like x[m][n]*y[n][k]).
3- a code to get name and some grades of some students and then print them.(like other it should use dimensional array)
dear, please refer thinking in c++ book on net, it' free! download from mindview.net
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello,i study the windows via c/c++.but i have some problems about this routine.
//Wiews must always start on a multiple of the allocation granularity
SYSTEM_INFO sinf;
GetSystemInfo(&sinf);
//Open the data file.
HANDLE hFile = CreateFile(TEXT("C:\\HugeFile.Big"), GENERIC_READ, FILE_SHARE_READ\
, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
//Create the file-mapping object.
HANDLE hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
DWORD dwFileSizeHigh;
_int64 qwFileSize = GetFileSize(hFile, &dwFileSizeHigh);
qwFileSize += (((_int64)dwFileSizeHigh) << 32);
//we no longer need access to the file object's handle.
CloseHandle(hFile);
_int64 qwFileOffset = 0, qwNumOfos = 0;
while(qwFileSize > 0)
{
//Determine the number of bytes to be mapped in this view
DWORD dwBytesInBlock = sinf.dwAllocationGranularity;
if(qwFileSize < sinf.dwAllocationGranularity)
dwBytesInBlock = (DWORD)qwFileSize;
PBYTE pbFile = (PBYTE)MapViewOfFile(hFileMapping, FILE_MAP_READ, (DWORD)(qwFileOffset >> 32), (DWORD)(qwFileOffset & 0xFFFFFFFF), dwBytesInBlock);
//Count the number of 0s in the block.
for(DWORD dwByte = 0; dwByte < dwBytesInBlock; dwByte++)
{
if(pbFile[dwByte] == 0)
qwNumOfos++;
}
//Unmap the view; we don't want multiple views in our address space.
UnmapViewOfFile(pbFile);
//Skip to the next set of bytes in the file.
qwFileOffset += dwBytesInBlock;
qwFileSize -= dwBytesInBlock;
}
CloseHandle(hFileMapping);
i can't understand the qwFileSize += (((_int64)dwFileSizeHigh) << 32);
and (DWORD)(qwFileOffset >> 32), (DWORD)(qwFileOffset & 0xFFFFFFFF)
can you tell me something? thank you.
|
|
|
|
|
See the description for GetFileSize()[^].
This code is taking the two result values and creating the 64-bit composite value, by shifting the high order bits 32-bits left, casting the result to an _int64 and adding to the low order value.
_int64 qwFileSize = GetFileSize(hFile, &dwFileSizeHigh);
qwFileSize += (((_int64)dwFileSizeHigh) << 32);
This code is extracting the two 32-bit halves of the value and passing them to the MapViewOfFile() function. In both cases the results need to be cast to DWORD s to keep the compiler happy.
PBYTE pbFile = (PBYTE)MapViewOfFile(hFileMapping, FILE_MAP_READ,
(DWORD)(qwFileOffset >> 32),
(DWORD)(qwFileOffset & 0xFFFFFFFF),
dwBytesInBlock);
It's time for a new signature.
|
|
|
|
|
|
Hello all.
I am programming a simple program in win32 console.
#include <stdio.h>
#include <conio.h>
main()
{
int i,j;
char list[80][20];
for(j=0;j<5;j++)
{
for(i=0;i<50;i++)
{
list[i][j]=getchar();
if (list[i][j]=='\n') break;
}
}
for(j=0;j<5;j++)
{
for(i=0;i<50;i++)
{
putchar(list[i][j]);
}
}
}
It should give some char and then print them. but when it want to print some other things (&%^&*vjc) print.
|
|
|
|
|
please read the forum guidelines ("how to ask a question"), use PRE tags, ask a specific question and provide symptoms if it does not do as you would like.
Suggestion: If it does not work, start with something simpler; do not enter 20 lines of code if you are not experienced enough to get the first 5 to work as expected.
And do you really want to enter up to 250 characters one by one?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
What should I do?
Can you help me on this method...
|
|
|
|
|
it is not clear what you want.
it is clear this is one of your very first attempts at programming; if it does not work, start with something simpler.
Do not start with 2-dimensional arrays, until you know everything there is to know about one-dimensional ones.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Im only guessing but..
Look at comments in the code.
Once you press enter, it exits the nested for loop and prints out what you put in.
#include <stdio.h>
#include <conio.h>
int main()
{
int i,j;
char list[80][20]={'\r' };
printf("\n input some chars ..\n\n ");
for(j=0;j<1;j++)
{
for(i=0;i<50;i++)
{
list[i][j]=getchar();
printf("%c = %d ",list[i][j],(int)(list[i][j]) );
if ( (int) (list[i][j]==10) )
{
printf("\n User pressed Enter: new line .. ");
break;
}
}
}
printf("\n\nListing..\n");
for(j=0;j<5;j++)
{
for(i=0;i<50;i++)
{
printf("%c",list[i][j]);
}
printf("\n");
}
printf("\n");
return 0;
}
......
|
|
|
|
|
When you create your arrays you're not initialising the contents to anything. Have a look at the rules for initialising automatic arrays in C and you might see what's wrong.
Get in the habit of initialising all variables as you declare them, it'll save loads of tears.
Cheers,
Ash
|
|
|
|
|
Since you stop collecting inputs at first newline but then ouput the whole array content, some resulting garbage is inevitable, I suppose.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello all.
I want to define an array in c win32 console. First column should be name & family of students and other columns should be grades of them.
NOW HELP ME : How can I have this array with first string column and other columns in float.
Thanks in advance.
|
|
|
|
|
Create a structure with name and grades as members.
struct _tagStudent
{
char Name[256];
float Math;
float Science;
}; Now you can create an array of Students.
struct _tagStudent Student[100];
You can access the members as follows -
Student[0].Name;
Student[0].Math;
Student[25].Name;
Student[25].Science;
|
|
|
|
|
how to know the parent item of a child tree item.
and how to traverse from last child item to root parent item.
|
|
|
|
|
1- GetParentItem ( HTREEITEM );
2- you'd loop over the items returned by GetParentItem until the item is TVI_ROOT (or something like that)
Watched code never compiles.
|
|
|
|
|
Sakhalean wrote: how to know the parent item of a child tree item.
and how to traverse from last child item to root parent item.
What do you have, i mean where do u struck? do you have HTREEITEM of child?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Sakhalean wrote: yes i have HTREEITEM
To Find Parent TreeItem:
call GetParentItem(child tree item)
To Find Root TreeItem:
HTREEITEM child = HTREEITEM of child;
HTREEITEM root = NULL;
do
{
root = GetParentItem(child);
child = root
}
while(root != NULL);
root will contain root tree item
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
|
Have u tried SetForegroundWindow??
|
|
|
|
|
Yes I had tried but that was not working so I was asking here
|
|
|
|
|
Did you only use SetForegroundWindow or combination of SetForegroundWindow and SetWindowPos???
Try This..
Sleep(5000);
::SetForegroundWindow(this->m_hWnd);
::SetWindowPos(this->m_hWnd, HWND_TOPMOST,0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|