|
CodeyBlank wrote: I am currently having some difficulty
Sorry, but we cannot guess what that difficulty may be. Please explain what the problem is. Does the code fail, and if so what happens - error code, abort, crash etc?
MVP 2010 - are they mad?
|
|
|
|
|
rats - you got there before me ...
'g'
|
|
|
|
|
Still amazes me how many people think we can (read minds).
MVP 2010 - are they mad?
|
|
|
|
|
Richard MacCutchan wrote: Still amazes me how many people think we can (read minds).
Since I know 'a priori' that, it doesn't amaze me: yes we can (not in Massachusetts, however).
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]
|
|
|
|
|
MVP 2010 - are they mad?
|
|
|
|
|
ok, are we supposed to guess whats happening (or not happening) ?
a) ie, where does it fail ?
b) have you single-stepped through it in debug mode ?
c) is there some sort of run-time error or any other diagnostics in your system ?
most guys would love to be able to help, but we dont read minds (my own is bad enough !!)
'g'
|
|
|
|
|
I am able to send text message when using Hyper Terminal but currently I am making it run without Hyper Terminal. There is no compiling error, but it can't send out any text message. Hoping to know is there any logic error. Please guide me along. Thank you
|
|
|
|
|
the problem is the command set would be unknown to most of us here.
a) how do you verify that the commands you're sending programmatically to the device are being received and acted on - there doesnt seem to be any status returns/checks from [putrsUSART] - you've just said do a,b,c,d etc, and there doesnt seem to be any return saying the commands are accepted or not - if you were calling a function of your own, for example, you'd have some sort of return indicator to say the function worked or not wouldnt you ?
b) what commands do you issue in hyperterm ? list them
c) if you compared those commands from (b) to what you think your code is doing, is it doing fundamentally the same ?
thats where I'd start
'g'
|
|
|
|
|
Hi,
Anyone knows how to split the tif file using CXImge library?
Thanks,
|
|
|
|
|
i am also used cxImage library ..but i coudnt understood what u need ?can u explain .... little more
Failure is Success If we learn from it!!
|
|
|
|
|
Hi,
I am having multipage tiff file. I want to convert to separate files. Is there any function in CXImage library to split multipage tiff files?
Thanks,
|
|
|
|
|
I do not know about CxImage, but Gdiplus::Image can do it easily via calls to GetFrameCount() and SelectActiveFrame() .
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
in vc2008:
#include <fstream><br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif
----compile success
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif<br />
#include <fstream>
----compile error
d:\program files\microsoft visual studio 9.0\vc\include\xdebug(32) : error C2365: “operator new”: redefinition.....
can anybody explain?
modified on Wednesday, January 20, 2010 7:14 PM
|
|
|
|
|
one of those #includes is defining its own version of new ?
|
|
|
|
|
but why:
#include <fstream>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
----can compile success?
|
|
|
|
|
Hello all,
I am working on my homework for my C++ programming class and I am hitting a brick wall. Everywhere I look online does not seem to have any information in which I can apply to my program. I am supposed to use a "while" loop which I am, and thats working.
The part which is not working is the users input should add it to the previous entry, and after the user types "0" it will display the sum on the screen. I have looked at the following references to try and make sense of things:
http://www.cplusplus.com/reference/std/numeric/partial_sum/[^]
http://www.cplusplus.com/reference/std/numeric/accumulate/[^]
http://frank.mtsu.edu/~csci117/manual/lab7/lab7.html[^]
I am trying very hard to understand this, but I can not find a good online reference of the libraries. www.cplusplus.com is very good but dosent have the info I need, or more than likely I can not find it.
But here is the code to which I am trying to correct:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int userinput;
int sum = 0;
sum = sum + userinput;
while (userinput != 0)
{
cout << "Please enter a number. When you are finished, type 0 and press Enter." ;
cin >> ++userinput ;
}
cout << "The sum is:" << sum << endl;
return 0;
}
Thank's to all in advance for pointing me in the correct direction so I can figure this out. I should have put this at the top: I DO NOT WANT THE ANSWER, I WOULD PREFER THE REFERENCE TO FIND MY OWN.
|
|
|
|
|
Outside the loop you should initialize the variable "userinput". The statement
sum = sum + userinput
before the loop should be removed. This statement should appear somewhere inside the loop. Also, for this you can use the += operator instead. The ++userinput inside the loop should just be userinput without the ++ operator.
The variables "userinput" and "sum" are not "Global Variables". They are local to the function "main".
You need to work out the details.
|
|
|
|
|
Thank you very much. I got it working now. I read over this while I was at dinner with the wife and figured it out at the dinner table!
here is the working code:
#include <iostream>
using namespace std;
int main()
{
int userinput;
int sum = 0;
while (userinput != 0)
{
cout << "Please enter a number. When you are finished, type 0 and press Enter." ;
cin >> userinput ;
sum = sum + userinput;
}
cout << "The sum is:" << sum << endl;
return 0;
}
|
|
|
|
|
Even though this program works, you are relying on the variable userinput having an initial non-zero value. The compiler actually does not always guarantee that. To make the program robust, I suggest you take control on the values of variables and not rely on some random factors.
Good luck and happy programming!
|
|
|
|
|
Now that the program adds the numbers and provides the sum at the end, I need to provide a means of displaying how many times a user input something.
The example output would be:
Sum = 134
Total numbers of inputs = 8
So I have been looking to find something on counters. I have looked at multiple web sites yet again and can not find anything. I have fixed my previous code and it is listed below. Once again, I DO NOT WANT THE ANSWER, I WANT THE REFERENCE SO I CAN LOOK IT UP MYSELF. Being pointed in the right direction helps me most.
Thank you all again.
#include <iostream>
using namespace std;
int main()
{
int userinput;
int sum = 0;
int count = 0 ;
cout << "Roberts Number program v1" << endl;
cout << endl;
cout << endl;
cout << "When you are finished, enter '0'" << endl;
cout << endl;
while (userinput != 0)
{
cout << "Input a number, then press enter. " ;
cin >> userinput ;
sum += userinput;
}
cout << "The sum is:" << sum << endl;
return 0;
}
|
|
|
|
|
rbwest86 wrote: counters
A counter is just a variable that holds a number. So per your requirement I will reword it to provide the hint that you need...
Each time that the user enters a number, increase the counter, then when the user is done entering numbers, output the number of times that the user entered a value.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hello people!
Here's a simplified version of what i am trying to do (sorry for the long code):
class CTestClass
{
public:
void AMethod(int x);
BOOL BMethod(char y);
};
template<typename TParamType>
class TTestTemplate
{
typedef void(CTestClass::* LPFN_AMETHOD)(TParamType);
typedef BOOL(CTestClass::* LPFN_BMETHOD)(TParamType);
bool fIsAFn;
union {
LPFN_AMETHOD fnA;
LPFN_BMETHOD fnB;
};
public:
TTestTemplate(LPFN_AMETHOD pFn):fnA(pFn), fIsAFn(true ) {}
TTestTemplate(LPFN_BMETHOD pFn):fnB(pFn), fIsAFn(false) {}
void Call(CTestClass *pInstance, TParamType val);
};
template<typename TParamType>
void TTestTemplate<TParamType>::Call(CTestClass *pInstance, TParamType val)
{
if (fIsAFn) (pInstance::*fnA)(val);
else (pInstance::*fnB)(val);
}
At the highlighted line i am getting an INTERNAL COMPILER ERROR, i googled around and this seems to be a bug in the compiler (am not absolutely sure though), so my question is: does anyone maybe know of any workaround for this? I am using VC++ 2003 (using a newer version of VC++ is sadly not an option since this is out of my hand, i am stuck with it). If i could somehow get it to work it would simplify my life a lot...
[ANSWER] Ok, seems to be that i am trying to call the methods thorough the pointers wrong, if i use this:
(pInstance->*fnA)(val); instead of the :: version it compiles and runs fine. So i guess the bug is that it does not give any usefull error not that it can't "eat" function pointers and templates together. What are the odds...[/ANSWER]
> 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. <
modified on Tuesday, January 19, 2010 12:56 PM
|
|
|
|
|
pInstance is class instance. Did you ever see any people use it like:
pInstance::
For a class pointer, using "pInstance->" is correct.
"::" is just for "class" or "namespace"
|
|
|
|
|
Yes, as you can see on my post i realized that already, but thank you, i would have noticed that sooner if the error message i got would have been something like "don't use :: on that, you moron" instead of "duh, compiler is broke, boohoohoo"...
> 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. <
|
|
|
|
|
Does anyone have the book "Programming Microsoft Visual C++ 5th Edition, David J. Kruglinski, George Shepherd, and Scot Wingo"? I bought the book secondhand but it never came with a CD because it was lost. I manage to type up the code listings to try out the examples. However am stuck on chapter 12: Windows Message Processing and Multithreaded Programming. Apparently the example 12B & 12C relies on 12A code, however it doesn't do complete listings for 12B or 12C but vaguely describes changes. I don't think it's explained all changes because I can't get it to compile.
Just wondering if anyone had the CD (code listing files) for this book?
|
|
|
|