|
You're very unlikely to get an answer to such posts as it is very long and people here may not have the time to look at it.
You should read Chris' message How to get an answer to your question[^]
Finally, I think you should use a debugger and single step through your code.
And it would help if your code is properly indented.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
forensicgeek wrote: I wasn't sure so I included the whole program...
First mistake is there's never a reason to include so much code.
forensicgeek wrote: ...if anyone can figure out why whats wrong please let me know!
Second mistake is asking others to wade through all of this code. It's your assignment, after all.
Third mistake is that you did not read (or did but chose to ignore) this, especially point #7.
Rather than just run the program and hope it spits out the correct answer at the end, consider stepping through it using the ever-helpful debugger. You may not find the exact problem with it, but you can very easily narrow it down to just a small handful of lines rather than a whole program.
"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
|
|
|
|
|
You can get through any maze by putting your right hand on the wall as you enter, then keeping your right hand on the wall as you walk through the maze.
I.e., whenever you have the opportunity to turn right, do it, still keeping your right hand on the wall.
When you reach a dead end, you loop around, still keeping your right hand on the wall at all times.
This will get through any maze. Another name for this search pattern is a Depth-First Search (http://en.wikipedia.org/wiki/Depth-first_search[^]).
|
|
|
|
|
Is there any way to get the time as represented on another computer on a LAN.
Regards,
Bram van Kampen
|
|
|
|
|
Use NetRemoteTOD() .
"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
|
|
|
|
|
Thanks,
Works a Treat. Blessed are those that remember all those Windows API Names.
Regards,
Bram van Kampen
|
|
|
|
|
Hi,
I'm going to write small app ( in C++) for creating music, which would work under Win Xp, and I need some means for playing samples and streaming raw audio data.
I've looked up for some audio apis but I have no idea which one would be the best to perform this task. I've found some info about core audio APIs and I think that they would be right choose for my app. Unfortunately, as I know, they are just available for Vista and probably Win 7. That's why I would be grateful if you could give me some alternatives for this API (It also can be some cross-platform API).
Thanks in advance for help.
modified on Friday, September 18, 2009 3:06 PM
|
|
|
|
|
|
Thanks for that, but I forgot to mantion that I want to write in C++ rather than C. So I would need some c++ API.
Heh, I've just realised that ASIO is an API. So, thank you one more time for help.
|
|
|
|
|
Hi,
I have a process that need to check a string formating. How the best way to check it ?
My client receive a e-mail with a field to fill a date "DD/MM/AAAA". when i receive the answer i need to check if the "/" and values for DD, MM and AAAA
or
My client receive a e-mail with a field to fill a value "9999" with range 10 to 1500.
I whould like a way to check it directy for true or false.
Someone can help me ?
|
|
|
|
|
for the date thing, i would just do it with simple CString search functions.
off the top of my head....
if (inString.GetLength()==10)
{
if (inString.GetAt(2) == '/' && inString.GetAt(5) == '/')
{
csDD = inString.Mid(0, 2);
csMM = inString.Mid(3, 2);
csYYY = inString.Mid(6, 4);
}
}
that's really brittle and won't accept things like "9/28/1927" or "5/5/05". but if you want to strictly enforce two-digit D and M and four digit Y, then that's all you need.
|
|
|
|
|
Use CStringT::Tokenize[^].
In this case the function must return 3 values in a loop.
The first value will be DD and the next MM and the next AAAA.
You could do the validation on these values.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
SNArruda wrote: My client receive a e-mail with a field to fill a date "DD/MM/AAAA". when i receive the answer i need to check if the "/" and values for DD, MM and AAAA
For dates, how about something like:
COleDateTime date;
date.ParseDateTime("17/9/2009");
if (date.GetStatus() != COleDateTime::valid)
...
"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
|
|
|
|
|
Can anyone suggest a good study book for C/C++/VC++2008.
The book should be intermidiate/advanced.
My background is that i have read Programming in C by Byron S. Gottfried.
|
|
|
|
|
Here[^] is my list of recommended books.
|
|
|
|
|
Ivor Horton has a good book on Visual C++ 2008.
He teaches C++ in the first half of the book and Windows Programming in the second half. He's still uses MFC for most of the book (which is a good thing IMO) but he has adapted and incorporated WinForms and some managed code for those who want it.
I've been very impressed with his teaching style and his choice of topics to cover.
|
|
|
|
|
#include<stdio.h>
#define abs(x) ((x<0)?(-(x)):(x))
#define epsilon .000000000001
#define size 5
double multiply(a,m,product)
double a[size][size],product [size][size];
int *m;
{
int test=0;
int count,i,j,k,l;
double olda[size][size],diff;
for(i=0;i<*m;i++)
for(j=0;j(* m;j++)
olda[i][j]=a[i][j];
for(count=1;count<=1000;count++)
{
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
product[i][j]=0;
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
for(k=0;k<*m;k++)
product[i][j]=product[i][j]+a[i][k]*olda[k][j];
for(i=0;i<*m;i++)
for(j=0;j<*m;j++)
{
diff=abs(product[i][j]-olda[i][j]);
if(diff>epsilon)
{
test=1;
for(k=0;k<*m;k++)
for(l=0;l<*m;l++)
olda[k][l]=product[k][l];
}
break;
if(test<1)
{
printf("\nThe numberof iterations is:");
printf("\n");
printf("\n %d",count);
break;
}
test=0;
}
return(0);
}
main()
{
static double a[size][size]={{0.1,1.0,0.0,0.0,0.0},
{0.0,0.0,0.3,0.7,0.0},
{0.0,0.0,0.0,0.2,0.8},
{0.0,0.0,0.1,0.0,0.9},
{1.0,0.0,0.0,0.0,0.0}};
double product[size][size],pi[size],diff;
int test;
int m=size;
int i j;
multiply(a,&m,product);
printf("\n");
printf((" \nThe product is:");
printf("\n");
for(i=0;i<m;i<m;i++)
{
printf("\n");
for(j=0;j<m;j++)
printf(" %15.12f", product[i][j]);
}
printf("\n");
printf("n");
return(0);
}
I tried to compile this and I got errors thank you for your input. I apologise for not posting this correctly yesterday.
|
|
|
|
|
belleissexy333 wrote: I tried to compile this and I got errors thank you for your input
It would really help if you post the exact error messages. They are there for a reason you know
Anyway, at first sight the block of for loops seems very strange...
|
|
|
|
|
The compiler tells you at what line the error occurs and what is the error. Could you please provide us this useful info?
Anyway, the following lines looks wrong:
belleissexy333 wrote: for(i=0;i<m;i<m;i++)
belleissexy333 wrote: for(j=0;j(* m;j++)
BTW: why the m parameter of the multiply function is a pointer (you always access just its value)?
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]
|
|
|
|
|
|
I just got this error yesterday with VS 2005. I thought it had been solved with SP1, but it hadn't. My solution was to access the class view from the header. Don't know why it worked.
|
|
|
|
|
I using Window CE API WriteFile() to write some barcode data to a file. Data is scanned and written to file ok. Problem is everything is on one line. How can I get the data in the file to be
line based. In other words, everytime I write to the file it writes a new line.
Thanks
|
|
|
|
|
Hi egerving,
The escape sequences for newline [^]in C/C++ is '\n'
Best Wishes,
-David Delaune
|
|
|
|
|
If Randor's suggestion doesn't work, you should try writing "\r\n".
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Using MFC & VC6
I am terribly confused about how to move CWnd objects around. With screen coords, client coords, dialog units, screen units, AaaRGh.
I have dialog app with button controls. From the OnSelect function of the buttons I am calling another popup dialog of my own making. I want to position the popup dialog so it obscure certain areas of the main dialog.
I am trying to use CWnd::MoveWindow() to move my popup dialog in the OnInitDialog() function to a position relative to the top left postion of the main dialog.
Which methods should I be using to get the main dialogs position to calculate coords for the MoveWindow() function in the correct units. A small example would be useful. Has anyone made a small Class to handle all this confussing translation between all the possible units and coordinte references ?
|
|
|
|