|
so friend i know you will have a headache cause of my questions. . but i wanna ask a final question. why there aren't any differences between sending the node or its address like this;
add_fn_Node(list,&pnew_stu);
add_ln_Node(list,&pnew_stu);
and replacing every code
pnew_stu->fn_next
pnew_stu->fn_pre
with
(*pnew_stu)->fn_next
(*pnew_stu)->ln_next
and of course sorry that silly mistake of malloc
|
|
|
|
|
If you want to make these changes, you will also have to change the prototypes of the add_XY_Node() functions so they correctly reflect the type of the second parameter.
If you do that, the suggested changes should indeed work: Instead of passing the pointer you pass the address of the variable that stores the pointer, but inside the function you dereference that address again to get the original pointer. I see no reason to do that, unless you want to modify the pointer and pass that modification back to the caller.
|
|
|
|
|
thanks for your help stefan
|
|
|
|
|
At first glance, this seems to be overly complicated. I looked back through my archives and found some code I did for a doubly-linked list (that simply held an integer). The data structures were:
struct _node
{
int m_nNumber;
struct _node* m_pNext;
struct _node* m_pPrev;
};
struct _list
{
_list( void )
{
head = NULL;
tail = NULL;
}
struct _node* head;
struct _node* tail;
}; The function signatures were:
void addToFront( struct _list* pList, int nNumber );
void addToBack( struct _list* pList, int nNumber );
void addBefore( struct _list* pList, struct _node* pNode, int nNumber );
void addAfter( struct _list* pList, struct _node* pNode, int nNumber );
void insertAscending( struct _list* pList, int nNumber );
void insertDescending( struct _list* pList, int nNumber );
struct node* findNode( struct _list* pList, int nNumber ); To create a list of ascending integers, I would simply call insertAscending() , which looked like:
void insertAscending( struct _list* pList, int nNumber )
{
struct _node* pTemp = pList->head;
while (pTemp != NULL && nNumber > pTemp->m_nNumber)
pTemp = pTemp->m_pNext;
addBefore(pList, pTemp, nNumber);
}
void addBefore( struct _list* pList, struct _node* pNode, int nNumber )
{
struct _node* pTemp = new struct _node;
pTemp->m_nNumber = nNumber;
pTemp->m_pNext = pNode;
if (pNode->m_pPrev == NULL)
pList->head = pTemp;
else
pNode->m_pPrev->m_pNext = pTemp;
pTemp->m_pPrev = pNode->m_pPrev;
pNode->m_pPrev = pTemp;
} Breaking your code down into smaller, more manageable pieces will help you a lot.
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
well mate i know my code is a little bit complicated but its reason is i am just in the beginning level of my project. i will make these operations at the end . anyway thanks for your suggestions
|
|
|
|
|
Hey Friends
I downloaded google chrome, clicked on download button, a eula was displayed and volla google chrome was downloaded and installed without any UAC prompt.
That's really nice , however when i create my own setup applications (with InoSetup) they display uac prompt.
If UAC prompt can be removed from setup, it would be great , is'nt it?
Any idea how google chrome setup is doing the magic?
Regards
|
|
|
|
|
For one thing. Chrome gets installed (on Win7) to C:\Users\Hans\AppData\Local\Google\Chrome. This is a user-accessible folder (unlike Program Files), so no UAC prompt.
Note: there might be other things that suppress the UAC interaction.
|
|
|
|
|
nops that does not seems correct.
the uac prompt is displayed before even the installation begins.
|
|
|
|
|
As I said, there might be other things involved, besides the installation folder.
Raj Aryan 1001 wrote: the uac prompt is displayed before even the installation begins. I have no idea what this means. You mean before you even click on the install package, you get a UAC prompt? That makes no sense.
Some other things: does your install package reference the registry? Have you checked the manifest settings?
|
|
|
|
|
forget about my installer, let's take any other installer, let's say internet explorer
when you download it will ask you whether to run it or save it?
google chrome does not asks to run it or save it, it just gets started automatically
now here the thing is that probably google chrome installer is running on my pc without any prompts whatsoever
installation page of google chrome
[^]
ie http://windows.microsoft.com/en-US/internet-explorer/products/ie/home[^]
|
|
|
|
|
Do you have a googleupdate app running on your PC?
|
|
|
|
|
yeah, is that the magic?
i have google toolbar installed
|
|
|
|
|
Raj Aryan 1001 wrote: yeah, is that the magic? Yep.
Sorry I misunderstood what you were asking.
|
|
|
|
|
that's brilliant, you cracked it
these hidden services can do anything
you are just brilliant, thanks
|
|
|
|
|
Raj Aryan 1001 wrote: it would be great , is'nt it?
No. If one user were able to install an app, remove an app, or alter an app in a way that affects all users of the system, it would not be great. It would be unsafe.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
yeah correct, but if application can get installed atleast for signed on user without uac prompts then it would be better i think (if it asks for admin password and user does not have admin password then user will not be able to install it and may be google chrome can be installed, will check)
|
|
|
|
|
Hi,
I am trying to make a brick game. I want to have a class for the players ball. The ball will split in 3 when a certain item is collected. The code compiles fine but when it runs it gives me the error "Object reference not set to an instance of an object." Also what's the best way of writing the code for 3 ball objects without having to duplicate code 3 times. Thanks.
#include "stdafx.h"
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Ball
{
public:
PictureBox^ gameBall;
int speed;
double xVel;
double yVel;
Ball()
{
}
void Add_to_form( Form ^ form )
{
speed = 5;
xVel = speed;
yVel = speed;
gameBall = gcnew PictureBox();
gameBall->BackColor = Color::LimeGreen;
gameBall->Size = Drawing::Size(20,20);
gameBall->Location = Drawing::Point(form->Width/2-35,form->Height/2-50);
form->Controls->Add(gameBall);
}
};
public ref class Form1 : public Form
{
public:
PictureBox^ paddlePlayer;
Timer^ gameTimer;
Ball ball1;
Form1()
{
this->Size = Drawing::Size(640,480);
this->BackColor= Color::SkyBlue;
this->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pongMain_MouseMove);
gameTimer = gcnew Timer();
gameTimer->Interval = 20;
gameTimer->Start();
gameTimer->Tick += gcnew System::EventHandler(this, &Form1::gameTimer_Tick);
paddlePlayer = gcnew PictureBox();
paddlePlayer->BackColor = Color::LimeGreen;
paddlePlayer->Size = Drawing::Size(128,16);
paddlePlayer->Location = Drawing::Point(this->Width/2,this->Height-65);
this->Controls->Add(paddlePlayer);
this->Controls->Add(ball1.gameBall);
}
System::Void pongMain_MouseMove( Object^, System::Windows::Forms::MouseEventArgs^ e)
{
if(e->X < this->Width-paddlePlayer->Width - 18)
{
paddlePlayer->Location = Drawing::Point(e->X,paddlePlayer->Location.Y);
}
}
System::Void gameTimer_Tick(System::Object^ sender, System::EventArgs^ e)
{
ball1.gameBall->Location = Point(ball1.gameBall->Location.X + Convert::ToUInt32(ball1.xVel), ball1.gameBall->Location.Y + Convert::ToUInt32(ball1.yVel));
if(ball1.gameBall->Location.Y < 0)
{
ball1.gameBall->Location = Point(ball1.gameBall->Location.X, 0);
ball1.yVel = -ball1.yVel;
}
if(ball1.gameBall->Location.Y > this->Height - ball1.gameBall->Size.Height - 45)
{
ball1.gameBall->Location = Point(ball1.gameBall->Location.X, this->Height - ball1.gameBall->Size.Height - 45);
ball1.yVel = -ball1.yVel;
}
if(ball1.gameBall->Location.X > this->Width - ball1.gameBall->Size.Width-25)
{
ball1.gameBall->Location = Point(ball1.gameBall->Location.X,ball1.gameBall->Location.Y);
ball1.xVel = -ball1.xVel;
}
if(ball1.gameBall->Location.X <= 0)
{
ball1.gameBall->Location = Point(ball1.gameBall->Location.X,ball1.gameBall->Location.Y);
ball1.xVel = -ball1.xVel;
}
if(ball1.gameBall->Bounds.IntersectsWith(paddlePlayer->Bounds))
{
ball1.gameBall->Location = Point(ball1.gameBall->Location.X,ball1.gameBall->Location.Y);
ball1.yVel = -ball1.yVel;
}
}
};
[STAThread]
int main()
{
Application::Run(gcnew Form1());
}
|
|
|
|
|
Please repost your message in Managed c++/CLI forum.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
Just create three instances of your Ball class. Instead of managing a single Ball instance, use a list of Balls, even when you only have one entry. Iterate over the list of balls each frame.
|
|
|
|
|
Thanks for the suggestion. It helped.
|
|
|
|
|
Hi,
I have created my own ownerdrawn menu, subclassed from CMenu, implementing the MeasureItem and DrawItem methods, which works flawlessly so far. However, I would like to change the visual appearance of the complete menu border, i.e. not the border of single menu items, but the whole menu border instead. Is there a good way to achieve this? Which method do I have to reimplement?
|
|
|
|
|
|
I recently have my huffman coding work by storing all of the character frequencies in an array sorted. The coding gives me the correct binary string for each character, but that is just for the characters in the array. What if I want to encode and display the binary characters coming from how they are arranged in the file itself?
Basically, my idea is that get each of these characters in the file and store them in a char string so that I can encode them from that point on. However, my program is weird because it outputs some characters but most are just blank. This is a section of the code that gets the characters from an input file and store them into a character array. counts_char is a function that gets the frequencies of each character; it also makes its instance of an input file stream.
char *stringChar;
ifstream infile( "project2input.txt" );
infile.seekg (0, ios::end);
size = infile.tellg();
stringChar = new char[size];
while(!infile.eof())
infile>>noskipws>>stringChar;
infile.close();
counts = new int[256];
count_chars( counts );
for (int k = 0; k<size; k++)
cout<<stringChar[k];
The output looks like this:
l ░↨l
♦ ^♂ É l É l 8 l 8 l 0l ╨
List of characters in the file with their frequencies:
E (0.0351617)
J (0.0351617)
- (0.0351617)
0 (0.0351617)
2 (0.0351617)
3 (0.0351617)
4 (0.0351617)
5 (0.0351617)
6 (0.0351617)
7 (0.0351617)
8 (0.0351617)
9 (0.0351617)
I (0.0703235)
M (0.0703235)
N (0.0703235)
O (0.0703235)
U (0.0703235)
W (0.0703235)
q (0.0703235)
z (0.0703235)
G (0.0703235)
1 (0.0703235)
T (0.105485)
k (0.105485)
C (0.175809)
x (0.21097)
; (0.246132)
j (0.246132)
S (0.281294)
. (0.351617)
A (0.457103)
v (0.703235)
w (0.914205)
g (0.949367)
y (1.16034)
, (1.6526)
f (1.86357)
b (1.89873)
u (1.9339)
m (2.00422)
(2.03938)
p (2.14487)
c (2.391)
d (2.63713)
l (3.41069)
h (3.44585)
s (4.99297)
i (5.16878)
r (5.30942)
a (5.37975)
o (5.66104)
n (5.9775)
t (6.8917)
e (10.9001)
(15.225)
2899 characters
Char Symbol Codes:
E = 0000000000000000000000000000000000000000000000000000001
J = 000000000000000000000000000000000000000000000000000001
- = 00000000000000000000000000000000000000000000000000001
0 = 0000000000000000000000000000000000000000000000000001
2 = 000000000000000000000000000000000000000000000000001
3 = 00000000000000000000000000000000000000000000000001
4 = 0000000000000000000000000000000000000000000000001
5 = 000000000000000000000000000000000000000000000001
6 = 00000000000000000000000000000000000000000000001
7 = 0000000000000000000000000000000000000000000001
8 = 000000000000000000000000000000000000000000001
9 = 00000000000000000000000000000000000000000001
I = 0000000000000000000000000000000000000000001
M = 000000000000000000000000000000000000000001
N = 00000000000000000000000000000000000000001
O = 0000000000000000000000000000000000000001
U = 000000000000000000000000000000000000001
W = 00000000000000000000000000000000000001
q = 0000000000000000000000000000000000001
z = 000000000000000000000000000000000001
G = 00000000000000000000000000000000001
1 = 0000000000000000000000000000000001
T = 000000000000000000000000000000001
k = 00000000000000000000000000000001
C = 0000000000000000000000000000001
x = 000000000000000000000000000001
; = 00000000000000000000000000001
j = 0000000000000000000000000001
S = 000000000000000000000000001
. = 00000000000000000000000001
A = 0000000000000000000000001
v = 000000000000000000000001
w = 00000000000000000000001
g = 0000000000000000000001
y = 000000000000000000001
, = 00000000000000000001
f = 0000000000000000001
b = 000000000000000001
u = 00000000000000001
m = 0000000000000001
= 000000000000001
p = 00000000000001
c = 0000000000001
d = 000000000001
l = 00000000001
h = 0000000001
s = 000000001
i = 00000001
r = 0000001
a = 000001
o = 00001
n = 0001
t = 001
e = 01
= 1
The portion before the list of characters is the one where the characters are supposed to be printed out as they were in the file.
Please help me with this. Thank you.
|
|
|
|
|
Francis Paran wrote: infile.seekg (0, ios::end);
When do you seek back to the beginning?
Francis Paran wrote: infile>>noskipws>>stringChar;
Is this supposed to append to stringChar ?
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I already got it working by having the ifstream variable initialized at the end using the ios::ate parameter on its instance. Thank you for the advice. I wouldn't have realized what I did wrong if it wasn't for your intuitive question, asking me when I seek back to the beginning.
|
|
|
|