|
Member 13128005 wrote: Any help?? You need to show your code, we cannot guess what it is doing.
|
|
|
|
|
How is the second dialog being created? Is it modal or modeless?
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Is your Dialog Modal?
Bram van Kampen
|
|
|
|
|
Hi,
I need help in solving the Linked List K reverse linked list problem.
Given a singly linked list and an integer K, reverses the nodes of the
list K at a time and returns modified linked list.
NOTE : The length of the list is divisible by K
Example :
Given linked list 1 -> 2 -> 3 -> 4 -> 5 -> 6 and K=2,
You should return 2 -> 1 -> 4 -> 3 -> 6 -> 5
Try to solve the problem using constant extra space.
Can anyone point me in the right direction?
Thanks.
|
|
|
|
|
The right direction is forward.
Using an array of K pointers would make the trick.
|
|
|
|
|
CPallini wrote: Using an array of K pointers
Wouldn't that break the condition to only use a constant amount of extra space (assuming this refers to memory usage)?
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Yes, you are right.
I was focused on the space complexity related to the list length. I see my assumption the 'the algo is O(1)' only holds if K is a constant.
|
|
|
|
|
Try to break the problem into sub-problems. For example:
- Given a singly-linked list of length k, reverse the order of the elements
- Given a singly-linked list of length 2*k, reverse the order of the first k elements, without touching the last k elements. Return a pointer to the kth element (counting from zero).
- Given a singly-linked list of length 2*k, reverse the order of the last k elements.
- Given a singly-linked list of length 3*k, reverse the order of the middle k elements. return a pointer to the 2*kth element (counting from zero).
- Put everything together to get the solution to your problem.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Break the problem into simpler tasks and implement functions for these:
1. write a function that reverses a full list. Make sure to adhere to the constraint to only use a constant amount of space (memory).
2. write a function to find the Nth element within a list from a given starting position (not actually needed, but will simplify the final program)
3. write a function to split off part of a given list before the Nth position
4. write code to retrieve sub-lists of length K using 2. and 3. and code to insert a (modified) sublist back at the original position.
5. use 1. and 4. in an iteration to process the entire list
All of these steps can easily be done with the help of at most two or three temporary references (pointers). The only tricky one is the reverse function.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Member 14055543 wrote:
Can anyone point me in the right direction? What code do you have so far? What help have you sought from your instructor? What does the problem/solution look like on paper (don't bother with code until you can complete this step)?
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I am facing an issue while printing some text using Ajantha Font, My observation says that after ANSI code 127 GDIPlus is not printing the correct font on windows 10 x64, where as GDI (Direct printing on DC does it correctly).
CFont font;
VERIFY(font.CreateFont(
40, // nHeight
20, // nWidth
0, // nEscapement
0, // nOrientation
FW_DONTCARE, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
FALSE, // cStrikeOut
DEFAULT_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH, // nPitchAndFamily
_T("AJANTHA"))); // lpszFacename
// Do something with the font just created...
CClientDC cdc(this);
CFont* def_font = cdc.SelectObject(&font);
cdc.TextOut(11, 11, _T("€ € ~ ƒ „ …"), 11);
cdc.SelectObject(def_font);
Font mFont(dc.m_hDC, font);
SolidBrush BlueBrush(Color(255, 0, 0, 255));
graphics.DrawString( strText, -1, &mFont, PointF(0, 150), pStringFormat, &BlueBrush);
// Done with the font. Delete the font object.
font.DeleteObject();
|
|
|
|
|
What is contained in strText and what exactly do you see on the output?
|
|
|
|
|
Adding to what has already been said ... read carefully
CreateFontA function | Microsoft Docs[^]
Read this bit carefully
Quote: To ensure consistent results when creating a font, do not specify OEM_CHARSET or DEFAULT_CHARSET. If you specify a typeface name in the lpszFace parameter, make sure that the fdwCharSet value matches the character set of the typeface specified in lpszFace.
Specifically you may want to look at the GDIPLUS font class
CFont Class | Microsoft Docs[^]
Quote: The font mapper does not use the DEFAULT_CHARSET value. An application can use this value to allow the name and size of a font to fully describe the logical font. If a font with the specified name does not exist, a font from any character set can be substituted for the specified font. To avoid unexpected results, applications should use the DEFAULT_CHARSET value sparingly.
Look at the sample code on the page and what setting they use, so what you really want to do for entirely predictable results is specify ANSI_CHARSET and use UNICODE strings, anything else is hit and miss
In vino veritas
modified 13-Nov-18 12:48pm.
|
|
|
|
|
Hi
i am trying to develop an application with following features:
The program starts in an user context, and during execution it will acquire admins rights,
can i accomplish this without the UAC Elevation?
If yes can you drive me to article that explains it?
Thanks in advance
|
|
|
|
|
|
Hello guys I'm trying to code in opengl so if anyone could help ill be posting info below
code:
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
using namespace glm;
int main(){
glewExperimental = true;
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window;
window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL);
if( window == NULL ){
fprintf( stderr, "Failed to open GLFW window. if you have an intel gpu they are not 3.3 compatible try the 2.1 version of the tutorials.\n" );
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental=true;
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return -1;
}
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
do{
glClear( GL_COLOR_BUFFER_BIT );
glfwSwapBuffers(window);
glfwPollEvents();
}
while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
glfwWindowShouldClose(window) == 0 );
}
error:
1>------ Rebuild All started: Project: opengl, Configuration: Debug Win32 ------
1> lov.cpp
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\trogd\documents\visual studio 2010\Projects\opengl\Debug\opengl.exe : fatal error LNK1120: 1 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
codeproject is what keeps me going :P
|
|
|
|
|
It appears that VS is trying to link before compiling, hence the message as the entry point _main should be created by compiling the above source into its object code. Check your project build settings.
|
|
|
|
|
You have setup a Console project to what is a Win GUI code or vice vesa.
When you first setup the project you had two choices windows console or windows GUI you selected the wrong one, whatever the case.
Not sure why you are staying on VS2010 rather than updating as it's free but on VS2017
You can change it after you make the project via
Project -> Properties -> Configuration Properties -> Linker -> System
It will be something similar on VS2010 and what you are after is subsystem and it will be either
Windows (/SUBSYSTEM:WINDOWS)
OR
Console (/SUBSYSTEM:CONSOLE)
Whichever one it is on currently it's wrong for the project, select the other.
In vino veritas
|
|
|
|
|
Functions to use when creating a mobile app using c++
|
|
|
|
|
|
I am using visual c++.net 2010 I get these errors
1>------ Build started: Project: last try, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\trogd\documents\visual studio 2010\projects\last try\last try\main.cpp(18): warning C4007: 'DllMain' : must be '__stdcall'
1>LINK : fatal error LNK1561: entry point must be defined
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
and here is the code also please tell me what is wrong and how I can fix it. thanks!
#include <Windows.h>
#define ADR_Test 0xB7CE50
void HackThread()
{
for(;;)
{
*(DWORD*)ADR_Test = 100000;
}
Sleep(180);
}
BOOL DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
}
return TRUE;
}
|
|
|
|
|
wrote: BOOL DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID) Should be BOOL __stdcall DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID) or BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID)
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hello friends,
I needed some hints/suggestion/brainstorm, so to go in a right direction.
I have lot of different Objects, based on which I need to generate a Text-file. This text is nothing but a Scripting Language with some specific rules or grammars. ( Example, like a VB script ).
A simple/legacy way could be, Iterate all the objects, and Append hard-coded text ( to a global string), with many if and else cases.
Now, I am looking if any framework/design/principle is available, or I can make use of it, to make a clean design/code instead writing lot of if and else. One I found is boost karma, but looking for alternatives to make the best choice.
Seeking your valuable advises.
Thanks in advance,
|
|
|
|
|
Make the object classes inherit from a common interface exposing, say, a toString method an d then call it on all the object instances.
|
|
|
|
|
Thank you for your advice. Sure it is part of the solution.
I was looking more on making the script file ( that is the text of the scripts), as in how should I do that. Shall I simply make a hard-coded string with lot of if and else ( from the objects), and append them one by one, or do we have a fit design Pattern for this. Keeping in mind there would be some rules for the script generation, I would love to make it cleaner with some well design structure.
|
|
|
|
|