|
THX!
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Hi,
Just wanted to drop in and let you know that I have not forgotten about your issue. Unfortunately I was out of town last weekend and did not write any code. I still have it on my TODO list so let me know if you have solved your problem.
|
|
|
|
|
Thanks! Wait ...![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Hmmmm,
Who are you? Are you RomTibi?
|
|
|
|
|
Randor wrote: Hmmmm,
Who are you? Are you RomTibi?
yeap
if u don`t mind
|
|
|
|
|
Hi, I have a program, it should be possible to optimize. I need advice: what program or application will to monitor how much memory is allocated to a given block of objects.
Thanks 
|
|
|
|
|
You can calculate it quite easily using the sizeof [^] operator.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
You can do this yourself from within Visual Studio by utilizing the CRT Debug Heap.
Debug Hook Function Writing[^]
Some other tips for reducing your application resources:
1.) Review all of your GDI code and optimize it. Try to reuse PEN,BRUSH and FONT objects. I have seen some engineers write GDI code that creates 10-15 GDI objects when they could have simply changed the properties of 2-3 existing GDI objects and reused them.
2.) Go through all of your data structures and check for unoptimized Data structure alignment[^].
3.) Comb through all of the functions in the project and look for ways to refactor and reuse variables. Modern C++ compilers such as Visual Studio will attempt to honor the scope "{" "}" operators. Most engineers believe: "Oh, don't worry... the C++ optimizer is so great that it will optimize those Temp variables away". While this is true to a certain extent... the compiler may also attempt to honor your scope brackets and this can sometimes lead to an increased usage of stack space depending on compiler settings.
4.) Comb through all of the functions and look for functions that are passing objects by value rather than by reference. Investigate to see if it is feasable to refactor the code so that the objects are passed by reference.
Thats all I can think of for reducing memory usage. Actually come to think of it... if your application is allocating thousands/millions of small objects... you might want to investigate the Low-fragmentation Heap[^]. All it really does is use a different algorithm for allocating memory that is tuned for smaller objects. When your application memory is massively fragmented... the problem for the allocator to solve is sorta like the 'knapsack problem' or 'bin-packing problem' however... the because the allocator sometimes can't find an already-allocated spot in the memory pool... it may just increases the size of the available pool.
Best Wishes,
-David Delaune
|
|
|
|
|
You can try deleaker Add-in for Visual C++ - I usually use it. 
|
|
|
|
|
C program to replace all the letters of a string with all 26 alphabets and to do permutations to all the substituted ones and finally store the resulted strings in a file..
please help me out in fixing this situation..
To be clear. let me quote an example:
If i havva simple 2 letter word eg: "TO". Then those two letters in the String "TO" are to be replaced by 26 English alphabets character by character individually..
like>>>
Given string: TO
OUTPUT should be like:
AO
BO
CO
DO
EO
.
.
.
ZO
and
TA
TB
TC
TD
TE
.
.
.
.
TZ
and the above generated string permutations(with repetition {n^r} ). such that we should get 26*26 ie.,676 permutations.
I hope u understood the logic..
And these whole set of 676 strings are to be stored in a file.
thanq...
|
|
|
|
|
Which part of this are you having a problem with? Generating the strings can be done in a simple loop, and writing to a file can be done with the fprintf() [^] function.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
yeah thanks for your reply Richard, but iam struck up with the loops. Can u please help me in fixing this problem..
|
|
|
|
|
This will generate your character strings:
char* pszString = "TO";
char szResult[5];
for (int i = 0; pszString[i] != '\0'; ++i)
{
strcpy(szResult, pszString);
for (char c = 'A'; c <= 'Z'; ++c)
{
szResult[i] = c;
printf("%s\n", szResult);
}
}
A bit of extra work would allow for any length of string and write your new strings to a file.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Show the code you've put together so far and we'll critique it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanx fr ur reply.
Here im able to replace with alphabets a letter by letter. and have a code for permutations even. But couldn't make it loop for replacing the character with all 26 alphabets..
CODE:
#include<stdio.h>
#include<string.h>
#include<conio.h>
main()
{
char *string = "dogood";
char zev[50];
int length = strlen(string);
printf("\n %d \n",strlen(string));
int i;
for(i=0;i<l;i++)
{
if(*string=='o')
string[i]='n';
else
zey[i] = *string;
*string++;
}
for(i=0;i<l;i++)
printf("%c",zey[i]);
printf("\n");
getch();
}
|
|
|
|
|
One solution would be to use a nested loop, like:
for (int i = 0; i < strlen(string); i++)
{
strcpy(zev, string);
for (char c = 'a'; c <= 'z'; c++)
{
zev[i] = c;
printf("%s\n", zev);
}
}
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
And regarding that file generation part, im a able to use fprintf() and all to save the so generated strings to the new file. But the position where im stuck up is at the loops only to replace all the 26 alphabets at every character position. Here is where i use fprintf() function:
#include<stdio.h>
#include<conio.h>
main()
{
FILE *fr,*fw;
char ch;
fr = fopen("input.txt","r");
fw = fopen("output.txt","w");
fprintf(fw,"The sequence is:---> ");
while(1)
{
ch = getc(fr);
if(ch==EOF)
{
break;
}
else
putc(ch,fw);
}
fprintf(fw,"\aThe combinations generated are:\a");
fclose(fr);
fclose(fw);
getch();
}
|
|
|
|
|
I think if we are clear.
My program should be like:
-------> If we give some string of length 'n' (eg: GAVC here its length is 4)
-------> This program should read this string GAVC from an input file and generate the permutations of those substituted in to the other file.
-------> Then every position in the string are to be <b>substituted by 20 letters</b> (A, C, D, E, F, G, H, I, K, L, M, N, P, Q, R, S, T, V, W, Y ) and <b>not with 26 alphabets</b> and then permutations should be done on those individual characters in the given string.
-------> Such that if we give the above string GAVC of length 4, the program should generate 20^4 permutations ie., 160000 combinations.
Please find a solution for me on this........
Thanq..
|
|
|
|
|
The code i have so far is:
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
int i;
FILE *fr,*fw;
fr = fopen("input.txt","r");
fw = fopen("output.txt","w");
char *string="gavc",zev[50];
int length = strlen(string);
printf("\n %d \n",strlen(string));
char ch;
fprintf(fw,"The string is:---> ");
while(1)
{
ch = getc(fr);
if(ch==EOF)
{
break;
}
else
putc(ch,fw);
}
int *ipCount = new int[strlen(zev)];
for(int i= 0;i<strlen(zev);i++)
{
ipCount[i]=25;
}
while(ipCount[0]>=0)
{
for(int j=0;j<26;j++)
{
printf("%s\n",zev);
zev[strlen(zev)-1]++;
ipCount[strlen(zev)-1]--;
}
for(int i= 1;i<strlen(zev);i++)
{
if(ipCount[0]==0)
{
ipCount[0]=-1;
}
if(ipCount[i]==0 )
{
ipCount[i-1]=ipCount[i-1]-1;
zev[i-1]++;
for(int k=i;k<strlen(zev);k++)
ipCount[k]=25;
break;
}
}
}
fprintf("fw","\n %s \n",zev);
fprintf(fw,"\n combinations generated are:\n");
printf("\n %s \n",zev);
fclose(fr);
fclose(fw);
getch();
}
|
|
|
|
|
hello all .
Actually i want to catch a Wrong Password Attempt to logon a system. Is there any API that can lead me to that event. If there is no then how would i be able to catch that event.
|
|
|
|
|
Please do not post the same question in multiple forums.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I assume the GINA dll could help you.
Or maybe have a look at the event viewer, maybe there's an API to read the event view ?
Watched code never compiles.
|
|
|
|
|
hi all,
waen i am sending AT+CPBR command to read phonebook entry,its reaturn value in UCS2 mode.
please help me decode this.
thanks.
|
|
|
|
|
|
I am trying to create a toolbar on my dialog, so I am creating it in the OnInitDialog() function, but the toolbar is not coming. please help me finding whats going wrong in this. Thanks Sujan
[code]
BOOL CDlgsViewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CToolBar m_FirstToolBar;
if(!m_FirstToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |
WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |
CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_FirstToolBar.LoadToolBar(IDR_MAINFRAME))
{
EndDialog(IDCANCEL);
}
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST,0);
return TRUE; // return TRUE unless you set the focus to a control
}
[/code]
|
|
|
|