|
goutom roy wrote: can any one can send me the code to send data?
You're a software developer, right?
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]
|
|
|
|
|
in the name of god
hello
why this causes error?????
atoi(&stck.top());
error when top from stack and using atoi to change it to integer.
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;
int compute(char* srt);
int main(){
int n;
cout<<"please enter the size of string and then the string:"<<endl;
cin>>n;//for example 3
char *str=new char[n];
cin>>str;//for example 12
compute(str);
}
int compute(char* str){
stack <char> stck;
stck.push(*str);
stck.push(*(str+1));
while(!stck.empty()){
int first=atoi(&stck.top());
cout<<"this is first:"<<first<<endl;
stck.pop();
int sec=atoi(&stck.top()); // WHY THIS CAUSE ERROR AND RETURN 12 INTEAD OF 1??????????
stck.pop();
cout<<"this is sec:"<<sec<<endl;
}
return 0;
}
|
|
|
|
|
You don't need the & inside the atoi function.
|
|
|
|
|
khomeyni wrote: int n;
cout<<"please enter the size of string and then the string:"<<endl;
cin>>n;//for example 3
char *str=new char[n];
cin>>str;//for example 12
This is fragile (what if the user inserts a longer string?).
khomeyni wrote: int compute(char* str){
stack <char> stck;
stck.push(*str);
stck.push(*(str+1));
while(!stck.empty()){
int first=atoi(&stck.top());
cout<<"this is first:"<<first<<endl;
stck.pop();
int sec="atoi(&stck.top());" why="" this="" cause="" error="" and="" return="" 12="" intead="" of="" 1??????????
stck.pop();
cout<<"this="" is="" sec:"<<sec<<endl;
}
return="" 0;
}<="" blockquote="">
This is a mess.
The function is confident that <code>(str+1)</code> is a valid address. That may be not true.
If you need to convert each single character into an integer then don't use <code>atoi</code>.
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]
|
|
|
|
|
thanks
i will take in mind your advises.
thanks.
valhamdolelah.
|
|
|
|
|
atoi() expects a char* rather than a char .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi All,
I am using CAcroAXDocShim classes for AcroPDF.dll in my project.
My projects main dialog uses this control to display the PDF's.
From my Main dailog, if i use the scrollbar, the PDF control dosent refresh properly.
i.e brown stripes gets in middle all over the PDF.
I taught of posting a refresh message to the PDF Control, but CAcroAXDocShim class dosent have a refresh method.
Can any one give me some suggestions on how i can get out from this refresh issue.
Thanks,
Kasi
|
|
|
|
|
Hi,
Is it possible to split view windows like frame frame window with CSplitterWnd?
class CMyWnd : public CView
{
protected:
DECLARE_DYNCREATE(CMyWnd)
public:
CMyWnd();
virtual ~CMyWnd();
CSplitterWnd m_sp;
};
BOOL CMyWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
m_sp.Create(this, 1,2, CSize(10, 10),
pContext);
if(!m_sp.CreateView(0, 0,RUNTIME_CLASS(CAview), CSize( 100, 300), pContext))return FALSE;
if(!m_sp.CreateView(0, 1,RUNTIME_CLASS(CCview), CSize(400, 300), pContext))return FALSE;
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
After doing above, to make window I did as followings.
program die...
Is it possible to split CView window with SplitterWnd?
CMyWnd *p = new CMyWnd;
p->Create(NULL, NULL, WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_OVERLAPPED | WS_VISIBLE|WS_BORDER,
CRect (10,80, 1280,1024), this, 100, NULL);
p->ShowWindow(SW_SHOW);
|
|
|
|
|
Hi
Hers's the problem :-
file:///C:/Users/dalia/Desktop/5th%20Lab/ACM%20Problems/674%20-%20Coin%20Change_files/674.htm
I tried to answer it but there is an error with Code ..
Would You please tell me what's wrong with it ?
#include<iostream>
using namespace std;
int main()
{
freopen("input.txt","r",stdin);
int n;
int d[5]={50,25,10,5,1};
int c[7490];
int s[7490];
int count=0;
c[0]=0;s[0]=0;
c[1]=1;s[1]=1;
for(int j=2;j<7490;j++)
{
count=0;
for(int i=0;i<=4;i++)
{
if((j-d[i])>=0)
{
c[j]=1+c[j-d[i]];
count++;
}
}
s[j]=count;
}
while(cin>>n)
{ cout<<s[n]<<endl;}
return 0;
}
Thanks
|
|
|
|
|
There's no user dalia in my computer.
--
Si dos montan un caballo, uno debe ir detrás.
|
|
|
|
|
|
Really? I thought all machines had the coursework pre-installed.
|
|
|
|
|
DaliaMagdy wrote: Would You please tell me what's wrong with it ?
Does it compile?
Does it run?
Do you get any error messages?
Please give us a clue.
|
|
|
|
|
Richard MacCutchan wrote: Please give us a clue.
The clue is in the 674.htm file, Richard. Are you just wanting it handed to you?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Sorry sir, my bad.
|
|
|
|
|
i really suggest you use meaningful array names, it could help drastically. then ponder it further.
|
|
|
|
|
|
I suppose your guess is correct.
It doesn't look the simplest task for a newbie. I think he needs to go recursive.
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]
|
|
|
|
|
If i only have C and i want to draw a transparent line the only solution i can think of:
- create a memoryDC and a compatiblebitmap
- Draw the line on the memoryDC
- Create a region that occupies the drawed line only
- Set this region to the DC
- copy memoryDC to DC transparently using Alphablend()
For a few lines this could work, but when drawing 100-dreds of lines the overhead is just too much.
Is there any more clever approach?
Rozis
|
|
|
|
|
I don't know how
Rozis wrote: If i only have C
limits this but try using GDI+[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Code-o-mat wrote: I don't know how
Rozis wrote:
If i only have C
limits this but try using GDI+[^].
It does: C does not know about the concept of classes while GDI+ is a class oriented API. GDI+ has also a function interface but MS itself disencourages this...
If there are any people here who have experience with this function interface of GDI+, please give me a yell...
Rozis
|
|
|
|
|
I can also think of 2 alternatives but both include doing the line drawing manually. So you write the line draw algorithm yourself and use GetPixel and SetPixel to perform the blending. You use GetPixel to get the color of your "target", calculate a new COLORREF using this color and your line color and blending, then you use SetPixel to display the pixel. This method will surely be slow since Get/SetPixel are slugs. The other i can think of is using a device-independent bitmap as a kind of "backbuffer", you place your target image onto this bitmap, do the line drawing and blending manually by directly reading-writing the pixel data of the bitmap (i suggest a 32 bit bitmap for a better speed) and then when you are done drawing all those lines, blit this buffer to the screen. This should be faster.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
|
I assume you did not intend to target that post at me.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I'll try to answer both...
Alphablend() has a parameter that determines a global transparency. Suppose I want 2 lines with different transparencies i must use Alphablend() 2 times. And drawing 2 times tranparently to the screen will change the original pixels (those that are not from the lines). In other words: I can copy the screen to the memoryDC, draw the line and alphablend it to the screen but then all pixels are changed. This is why a regionobject is required. So the solution of Rejeesh can not work.
The first suggestion of Code-o-mat is too slow. But his 2nd approach may have some opportunities. If i understand you well Code-o-mat essentially you say to me: manipulate the alpha-channel according to the line drawn... Thus if i could draw the line directly in the alpha-channel my problem would be solved. Unfortunally there's not such function... but maybe i can write one...
Maybe an approach can be: create a memoryDC, a 32-BPP bitmap and an addional 8-bit black and white bitmap. Draw the lines on the 8-bit bitmap (and also on the 32-bit bitmap) and finally merge the 8-bit image as an alpha-channel to the 32-bit bitmap. This means: no regions needed, no manual line draws and only one time comsuming operation (the merging of the alpha-channel. Sounds promissing!
Anyone any better ideas?
|
|
|
|