|
for(int i=0; pwcDC[i] != NULL; i++)
//How can be the above expression can be valid one that
is the one which is checking "pwcDC[i] != NULL" in which
we may actually be doing ABR( Array bound read) or anything so.
I am begginer in this so can u help me in this ?.
Thanks
Pavan
|
|
|
|
|
Assume you have an array of 5 pointers, the last slot always has a NULL value and the first 4 always have valid pointers. You can then loop through the array until you find the NULL pointer.
With rare exceptions, this is a terrible programming technique. It is best to simply use the known bounds of the array or, better yet, use a collection class.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
<small>Hi,
I am reading a text file line by and line and reading the values into variables using sscanf. The problem I am having is that sscanf will return the correct value for the number of columns that I have, however, it only puts the first value into first variable and ignores the remaining variables.
This is a snippet of the text file I am reading:
</small>
<code>Y8145L 0 1 1
Y8148L 0 1 1</code>
This is the code snippet:
<code>while(fgets(pointListID, sizeof(pointListID), unit1File))
{
if(feof(unit1File))
break;
double testA;
double testB;
double testC;
char testshortPointID[8];
if((sscanf(pointListID, "%s %d %d %d",&testshortPointID, &testA, &testB, &testC))==4)
{...}</code>
testA, testB and testC values never change when I run this.
Any help is appreciated!
Sande
|
|
|
|
|
for starters, %d is an int and %e is a float.
earl
-- modified at 18:51 Wednesday 12th July, 2006
Sorry, le should be a double.
|
|
|
|
|
Thanks ever so! I tried using %e and that wouldn't work, so I changed my doubles to float and presto!
Thanks alot!
sande
|
|
|
|
|
I edited my post, but le (or lf, I think) will do doubles for you.
earl
|
|
|
|
|
Thanks, I saw that... and it works! you're fabulous!!
sande
|
|
|
|
|
If you use C++ stream classes and strings instead of old non-typesafe C functions this kind of problem isn't possible. Here's a complete example with error checking:
---------------------------------
// Console.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
int main(int argc, char *argv[])
{
using namespace std;
// Open the file.
ifstream ifs("C:\\a.txt");
if (!ifs)
{
cerr << "Failed to open input file!" << endl;
return 1;
}
// Read in line at a time.
unsigned int LineNumber = 1;
string Line;
while (getline(ifs, Line))
{
// Now break up the line.
istringstream iss(Line);
string PointID;
int x, y, z;
if (!(iss >> PointID >> x >> y >> z))
{
cerr << "Error in line " << LineNumber << endl;
return 2;
}
++LineNumber;
// Output the results to the console for testing.
cout << PointID << ": (" << x << ", " << y << ", " << z << ")" << endl;
}
return 0;
}
---------------------------------
You want to change it to read doubles. Just make the following change with no need to alter a format spec and manually make sure it matches the variables:
double x, y, z;
Steve
|
|
|
|
|
I want to modify the color in the bitmap displayed in a window on screen in real time, for exemple for simulating a transition night/day.
Some pixel may have their color modified, other not.
Please can you indicate how I can create some filter or lookup table in order to implement such function in Visual C++.
Use of CPalette ? Other ?
Thanks for your help.
jean-marc.nakache@neuf.fr
|
|
|
|
|
Use GetBitmapBits to retrieve data of bitmap that displayed in a device context . Then change bytes of color and use SetBitmapBits .
|
|
|
|
|
Hello,
How can i convert any file format to tiff file format? Any DLL, source code or free app via command line?
Alternatively, can be a solution that convert any file to another format and later to a tiff format.
Any idea?
[]'s
Cris.
-- modified at 15:48 Wednesday 12th July, 2006
|
|
|
|
|
GDI+ is a dll that you can redistribute, that comes with any VC version > 6, or is in the PSDK for VC6. It can load TIFF as well as JPG/GIF/PNG.
I *think* it loads tiff.....
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
As Christian said, use GDI+. Be aware that it supports only SOME TIFF files. (Look at TIFF as a container of an image; how the image is actually formatted/compressed is essentially infinite. Before you get too alarmed, there are TIFF formats Apple has never published.) Fortunately, GDI+ handles the more common formats.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
But using GDI+, can I convert any file format to tiff? Or only image file to tiff?
|
|
|
|
|
I don't understand your question since GDI+ only handles image files.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
look at libtiff. libjpeg is also free.
|
|
|
|
|
Ok, but libtiff only convert image file to tiff file. I need to convert any file (readable) to tiff format.
[]'s
|
|
|
|
|
Right, which means you're going to have to do some work.
Starting with libjpeg to decompress jpegs and libpng to decompress pngs. gifs are easy to read, and bmps are trivial; those should cover most image formats.
Otherwise, if you don't need to build this into your program, irfanview will probably do what you want.
earl
|
|
|
|
|
Hello!
I have tried to create a jar-file in MS-DOS on this way:
jar cmf MittProg.txt MittProg.jar *.class
but... when I click on "enter" I see this:
jar is not a command, program or program file.
I have been on: java.sun.com/getjava
and I did install JRE but nothing happens.
what should I do, or how can I on some another way create a jar-file?
Please, help me...I will be very thankful!
/dino
beganovic_swe
|
|
|
|
|
I'm not sure why you expect people on an MFC forum to have the answer to this ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: I'm not sure why
Maybe his garbage collector hasn't run yet... be patient.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I had to write my question somewhere because I can not see any Java- forum...
It was more natural to write here than in e.g. html-forum because Java is a programming language too.
Where can I ask about Java? Please tell me?
beganovic_swe
|
|
|
|
|
i am using some JNI code and talking to a MFC extension DLL
I am using Visual Studio 6 . I get a crash when i try to create a window in one of the exposed functions . The crash seems to be in afxwin1.inl line 19 after the call to CreateEx
CHiddenWindow hiddenWnd ; <br />
<br />
extern "C" int APIENTRY<br />
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)<br />
{<br />
UNREFERENCED_PARAMETER(lpReserved);<br />
<br />
if (dwReason == DLL_PROCESS_ATTACH)<br />
{<br />
TRACE0("DLLWRAPPER.DLL Initializing!\n");<br />
<br />
if (!AfxInitExtensionModule(DllWrapperDLL, hInstance))<br />
return 0;<br />
<br />
new CDynLinkLibrary(DllWrapperDLL);<br />
<br />
}<br />
else if (dwReason == DLL_PROCESS_DETACH)<br />
{<br />
TRACE0("DLLWRAPPER.DLL Terminating!\n");<br />
AfxTermExtensionModule(DllWrapperDLL);<br />
}<br />
<br />
<br />
<br />
<br />
<br />
return 1;
}<br />
<br />
JNIEXPORT jint JNICALL Java_Blah1<br />
(JNIEnv *pEnv, jclass)<br />
{<br />
..<br />
hiddenWnd.CreateEx(0 ,::AfxRegisterWndClass( NULL) , NULL , WS_OVERLAPPED , CRect(10,10,10,10),NULL , 0);<br />
..<br />
<br />
}
Any ideas on this ?
Engineering is the effort !
-- modified at 14:23 Wednesday 12th July, 2006
|
|
|
|
|
Well you likely do not have the prerequisit envornment for creating a window since you are running in a Java Console Process! No WinMain no message queue etc.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
I have a .ocx file that I am trying to install on many computers. I have found code in MSDN which shows how to register ActiveX in Visual 6.0 C++. http://msdn2.microsoft.com/en-us/library/ms177531.aspx[^] I successfully put this code into my application so before my program starts up it checks the registry to see if the activeX is installed and if it is not then it will copy the file to the C:\ and install it. This is working for admins only right now.
I copy it to the C:\ and not the system32 folder because the user that is logged on may not have admin rights to do so.
My problem is installing ActiveX will not work if the user doesn't have admin rights. I have tried with my program and using "regsvr32.exe C:\my.ocx" which returns and error stating "DllRegisterServer in C:\my.ocx failed. Return code was: 0x8002801c".
I know there is a function where I can run a batch file as another user (like an admin user) but I dont have a global admins userid and password.
Is there anyway to register an ActiveX with a less privileged user?
Thanks Chris
|
|
|
|