|
I found a solution on my own. I posted it at the comments of the cximage article.
|
|
|
|
|
ofstream out("Matrices");
if(!out){
cout<<"cannot open file.\n";
return 1;
}
for(int i=0;i<row1;i++)
{for(int j=0;j<col1;j++){
out<<mat1[i][j];}}
out<<" *";
for(int w=0;w<row2;w++){for(int e=0;e<col2;e++){
out<<mat2[w][e];}}
out<<"=";
for(int u=0;u<row1;u++){for(int v=0;v<col2;v++){
out<<mat[u][v];}}
out.close();
in the followin part of code it is workin ver well but there is a proplem for me in the output
the output is
2333 *44=2024
how ever i want to make it in the way like that
2 3 * 4 = 20
3 3 4 24
or in any way so that the user can understand the output file & became able to know where is the first matrix is & the second one is and the output as well so
HOW CAN I DO THIS????????
|
|
|
|
|
Could you check the box that says
"Do not treat <'s as HTML tags"
and repost it?
|
|
|
|
|
It looks like you need to include some spaces in the output.
BTW, your post would be much more readable if it looked like:
ofstream out("Matrices");
if (! out)
{
cout << "cannot open file." << endl;
return 1;
}
for (int i = 0; i < row1; i++)
{
for(int j = 0; j < col1; j++)
out << mat1[i][j];
}
out << " *";
for (int w = 0; w < row2; w++)
{
for (int e = 0; e < col2; e++)
out << mat2[w][e];
}
out << "=";
for (int u = 0; u < row1; u++)
{
for (int v = 0; v < col2; v++)
out << mat[u][v];
}
out.close(); I suspect you are getting compiler errors from the bold lines. out should be cout instead.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
no there isnocompile errors becuse this out is to write inthe file
not cout
& istilldontknow what ihave todoin this proplem
i tried to use spaces inmany diffrent locations
but it is still dont come as i want so can u know wher exactly i have to put these spaces?
|
|
|
|
|
kosamoza wrote:
no there isnocompile errors becuse this out is to write inthe file
not cout
My bad. I did not look close enough to what you had.
kosamoza wrote:
i tried to use spaces inmany diffrent locations
but it is still dont come as i want so can u know wher exactly i have to put these spaces?
See if any of Christian's STL articles help with formatting:
http://www.codeproject.com/script/articles/list_articles.asp?userid=6556
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello there,
I tried to incorporate the following code segments in a VC++ project, and to compile it in Visual Studio. There were compiling errors beyond my comprehension. Any help are appreciated.
typedef void biasFn (void *image, void *bias, uint32 pixels);
#define subtract(bits) \
static void subtract##bits (void *i, void *b, uint32 pixels)\
{\
uint##bits *image = i;\
uint##bits *bias = b;\
while (pixels--) {\
*image = *image > *bias ? *image-*bias : 0;\
image++, bias++; \
} \
}
subtract(8)
subtract(16)
subtract(32)
static biasFn *lineSubtractFn (unsigned bits)
{
switch (bits) {
case 8: return subtract8;
case 16: return subtract16;
case 32: return subtract32;
}
return NULL;
}
|
|
|
|
|
Bugslayer1 wrote:
There were compiling errors...
I give up. What were the errors?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
When the VC++ compiles the following lines. It throws error messages:
subtract(8)
subtract(16)
subtract(32)
error C2440: 'initializing' : cannot convert from 'void *' to 'unsigned char *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
I also had hard to understand these lines of codes.
|
|
|
|
|
Ok, what is subtract() expecting?
You need to change lines in the subtract() macro to:
uint##bits *image = (uint##bits *) i;\
uint##bits *bias = (uint##bits *) b;\
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I do not know until I understand these lines of codes. The codes were compiled under Unix system. Problem is that I had a hard time to read the code. Can you explain to me what these lines of codes do?
|
|
|
|
|
Bugslayer1 wrote:
Can you explain to me what these lines of codes do?
No. You should be able to tell us what they do.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
No. I cannot. I got the code from libtiff http://www.libtiff.org[^]. One of the tools is tiffcp. I am trying to compile it using VC++.
|
|
|
|
|
I suggest using the /P compiler switch. It will expand that subtract() macro, and then you can see exactly what the problem is.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks for your help to expand the codes into a readable fashion. I still have some probelms although I made some progress with some changes.
typedef void biasFn (void *image, void *bias, uint32 pixels);
static void subtract8 (uint8 *i, uint8 *b, uint32 pixels)
{
uint8 *image = i;
uint8 *bias = b;
while (pixels--)
{
*image = *image > *bias ? *image-*bias : 0;
image++, bias++;
}
}
static void subtract16 (uint16 *i, uint16 *b, uint32 pixels)
{
uint16 *image = i;
uint16 *bias = b;
while (pixels--)
{ *image = *image > *bias ? *image-*bias : 0;
image++, bias++;
}
}
static void subtract32 (uint32 *i, uint32 *b, uint32 pixels)
{
uint32 *image = i;
uint32 *bias = b;
while (pixels--)
{
*image = *image > *bias ? *image-*bias : 0;
image++, bias++;
}
}
static biasFn *lineSubtractFn (unsigned bits)
{
switch (bits) {
case 8: return subtract8;
case 16: return subtract16;
case 32: return subtract32;
}
return 0;
}
......
biasFn *subtractLine;
TIFFGetField(in, 258, &sampleBits);
subtractLine = lineSubtractFn (sampleBits);
if (subtractLine) {
......
}
......
However, there are some errors I need to work out. Here are the error messages:
e:\vc++\libtiff\src\tiff\3.7.2\tiff-3.7.2-src\tools\tiffcp\tiffcp.cpp(975) : error C2440: 'return' : cannot convert from 'void (__cdecl *)(unsigned char *,unsigned char *,unsigned long)' to 'void (__cdecl *)(void *,void *,unsigned long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
e:\vc++\libtiff\src\tiff\3.7.2\tiff-3.7.2-src\tools\tiffcp\tiffcp.cpp(976) : error C2440: 'return' : cannot convert from 'void (__cdecl *)(unsigned short *,unsigned short *,unsigned long)' to 'void (__cdecl *)(void *,void *,unsigned long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
e:\vc++\libtiff\src\tiff\3.7.2\tiff-3.7.2-src\tools\tiffcp\tiffcp.cpp(977) : error C2440: 'return' : cannot convert from 'void (__cdecl *)(unsigned long *,unsigned long *,unsigned long)' to 'void (__cdecl *)(void *,void *,unsigned long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Any help is appreciated.
|
|
|
|
|
Notice that lineSubtractFn() is returning a biasFn* , but the function addresses that are actually being returned (i.e., subtract8 , subtract16 , subtract32 ) have a different signature.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
The lines 975-977 are
case 8: return subtract8;
case 16: return subtract16;
case 32: return subtract32;
|
|
|
|
|
As I indicated, those three functions do not have the same signature as the biasFn type.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Why, for your own sake, do you compile and use code, that you don't even know what it's doing?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Using macro's to generate functions like that, is very poor programming practice!
besides that, the type uintXX where XX is a number is not available in VC, use unsigned __intXX instead.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
does anyone know how to create an excel chart with c++?
|
|
|
|
|
Just embed the Microsoft Office Chart 9.0 into your program. It's contained in MSOWC.DLL.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I would like users of my program
to be able to launch their
currently installed email client
from within my program.
I would know the proper API call
to find the path to the executable
for the Email client that is currently
installed on a machine.
C/C++, Visual Studio 6.0
Many thanks,
Robert
|
|
|
|
|
Admitedly a cheesy solution, but it should get the job done.
HINSTANCE hInst = ::ShellExecute
(NULL, "open",
"mailto:ravib@ravib.com", <code>
"", "", SW_SHOW); <code>
ASSERT (hInst > 32); /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi,
Thanks for reply. I have used that
approach fro text messages.
The purpose of this feature is to allow
the User of my program to attach a file
to an email.
I believe that only very small files
can be attached with ShellExecute().
MAPI is another way to do it but MAPI
is a real mess of DLLs and various
users may not have the right version
of the MS MAPI DLL on their machine.
Also, some email clients like Eudora
require the user to specifically turn
on MAPI, so using MAPI complicates their
lives.
If I can find the default email client
then I can launch it with the attached
file as a command line parameter.
Thanks,
Robert
|
|
|
|