|
thank u friend.. but i am facing another problem...
Release folder automatically create right....
after change release mode...
i am trying to compile and run...
C:\bujji\server\Release\Server.exe
this file does not exist. do u want to build it?
yes no
i am clicking yes
cannot Execute program
|
|
|
|
|
Member 3653751 wrote: C:\bujji\server\Release\Server.exe
After compiling/linking, does C:\bujji\server\Release\Server.exe exist?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi
I have what I think to be a small problem.
I'm working with templated graph class that uses linkedlist for adjacent vertexes.
I'm just trying to test out the functions, but I keep getting a link unresolved error.
I'm thinking I might be typing it wrong, but who knows.
I'm using microsoft visual studio 2008.
thanks in advance.
here's my int main()
i purposely left out my openfile function
(it works,i've used it many times before) :
int main()
{
graphType<int,11> cGraph1();
ifstream fsFileIn,
fsFileIn2,
fsFileIn3;
openFile(fsFileIn,fsFileIn2,fsFileIn3);
cGraph1().createGraph(fsFileIn);
return 0;
}
here's most of the graphType.h file
(minus all the other header files graphType.h uses):
#ifndef H_graph
#define H_graph
#include <iostream>
#include <fstream>
#include <iomanip>
#include "linkedList.h"
#include "linkedListForGraph.h"
#include "queueLinked.h"
using namespace std;
const int infinity = 10000000;
template<class vType, int size>
class graphType
{
public:
void createGraph();
void createGraph(ifstream& infile);
void clearGraph();
graphType();
~graphType();
protected:
int maxSize;
int gSize;
linkedListGraph<vType> graph[size];
private:
void dft(vType v, bool visited[]);
};
template<class vType, int size>
void graphType<vType, size>::createGraph()
{
ifstream infile;
char fileName[50];
vType vertex;
vType adjacentVertex;
if(gSize != 0)
clearGraph();
cout<<"Enter the input file name: ";
cin>>fileName;
cout<<endl;
infile.open(fileName);
if(!infile)
{
cerr<<"Cannot open the input file."<<endl;
return;
}
infile>>gSize;
for(int index = 0; index < gSize; index++)
{
infile>>vertex;
infile>>adjacentVertex;
while(adjacentVertex != -999)
{
graph[vertex].insertLast(adjacentVertex);
infile>>adjacentVertex;
}
}
infile.close();
}
template<class vType, int size>
void graphType<vType, size>::createGraph(ifstream& infile)
{
char fileName[50];
vType vertex;
vType adjacentVertex;
if(gSize != 0)
clearGraph();
cout<<"Enter the input file name: ";
cin>>fileName;
cout<<endl;
infile.open(fileName);
if(!infile)
{
cerr<<"Cannot open the input file."<<endl;
return;
}
infile>>gSize;
for(int index = 0; index < gSize; index++)
{
infile>>vertex;
infile>>adjacentVertex;
while(adjacentVertex != -999)
{
graph[vertex].insertLast(adjacentVertex);
infile>>adjacentVertex;
}
}
infile.close();
}
template<class vType, int size>
void graphType<vType, size>::clearGraph()
{
int index;
for(index = 0; index < gSize; index++)
graph[index].destroyList();
gSize = 0;
}
template<class vType, int size>
graphType<vType, size>::graphType()
{
maxSize = size;
gSize = 0;
}
template<class vType, int size>
graphType<vType, size>::~graphType()
{
clearGraph();
}
#endif
|
|
|
|
|
You do understand that the Link Unresolved error has nothing to do with the project exerpts you present us? (There's no error text "link error unresolved" or similar text in the source)
I'd be willing to bet my little finger that it's not a Link(ed list) Unresolved Error, but rather a Link(er) Unresolved Error.
Have you double-checked to see that all required dependencies are included in the project - i.e .lib & .cpp files?
|
|
|
|
|
sorry,
linker unresolved error is exactly what i meant:
and yes, i do have all the necessary files in my project folder
and all the filenames match with my code declarations for the ifstream variable type.
I can declare a graph no problem, but when i try to use any functions, i get that linker error.
|
|
|
|
|
That's fine, there's no problem.
Okay - so what does this error message say?
Which file is not being found, or which functions are resulting in 'unresolved externals' type messages.
It sounds mighty like although the files are present in the project directory, they are not actually a part of the project. The IDE/makefile has to get told that they exist and to use them.
I.e - I notice that you have a number of .H files. Are their corresponding .cpp/.lib files included in the project - either via the project properties pane (.cpp) or the linker dependencies window (.lib files)
But for starters, what is the error message you recieve (please, cut and paste it - don't approximate or summarize it)
|
|
|
|
|
the .h files have all the code on them so it shouldn't be that.
here's the exact error message-
1>test.obj : error LNK2019: unresolved external symbol "class graphType<int,11> __cdecl cGraph1(void)" (?cGraph1@@YA?AV?$graphType@H$0L@@@XZ) referenced in function _main
1>J:\o\test1\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
Hmm. I must confess to having spent _very_ little time with templates. I'm afraid I can't help any further with this - I don't know enought to know.
|
|
|
|
|
its cool
thanks for trying
|
|
|
|
|
You didn't provide a body for your constructor and destructor of the GraphType class. Add { } after the constructor/destructor declarations.
Furthermore, remove the paranthesis after the cGraph1:
graphType<int,11> cGraph1;
|
|
|
|
|
Hi All,
I am using atof in my code and i have some problem in conversion.
CString samount = "32.33"
double damount = atof(amount);
float famount = atof(amount);
if i debug and check damount and famount, they have following values
damount has 32.3299999
famount has 32.330002
the damount is used in many calculations and i am thinking those calculations will resulat wrong.
Did some one know how i can make sure to returan the correct double value from a string.
or Are there any libraries that i need to use to get the correct value.
Thanks.
|
|
|
|
|
Well, double has more precision than float and that is what you're seeing most likely. Most values can't be represented exactly in either float or double so the approximate values will vary if you compare directly. For this reason, you can almost never reliably compare floating point values for equality. In fact, as you're seeing, you probably need to be careful about inequalities when the values being compared are "close". You always need compare using an "epsilon" value, a small value indicating "close enough". Similarly, you need to be careful the ordering of calculations if the values vary wildly in range. For instance, subtracting a small value from a large one may result in no change at all.
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
|
I am trying to make an INI file in
C:\Documents and Settings\All Users\Application Data\MyApp
I know WritePrivateProfileString will write a new file if one does not exist, but if I try
#define INI_FILENAME "C:\\Documents and Settings\\All Users\\Application Data\\MyApp\\MyApp.ini"
WritePrivateProfileString("My Section", "My Name", "My Value", INI_FILENAME);
It will only make a new ini file if the directory exists.
Is there a workaround for this? If not, how do I check to see if a directory exists, and make a new one?
|
|
|
|
|
malaugh wrote: how do I check to see if a directory exists, and make a new one?
SHCreateDirectoryEx
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
SHCreateDirectory can create the full path with just one call.
|
|
|
|
|
the window sdk's function to operation "*.ini", like function WritePrivateProfileString and more,it's very inconvenient.
so you can use this class in your program (if the section isn't exiting,it will create himself.)
#if !defined(AFX_OPINI_H__CE3F8B7B_1ACA_46CC_A91C_F8E23FA9B063__INCLUDED_)
#define AFX_OPINI_H__CE3F8B7B_1ACA_46CC_A91C_F8E23FA9B063__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxwin.h>
class COPini
{
public:
static DWORD ReadString (char *section, char * key, char stringtoread[], char * filename);
static BOOL WriteString(LPCTSTR section, LPCTSTR key,char* stringtoadd, char *filename);
COPini();
virtual ~COPini();
};
#endif // !defined(AFX_OPINI_H__CE3F8B7B_1ACA_46CC_A91C_F8E23FA9B063__INCLUDED_)
#include "stdafx.h"
#include "OPini.h"
COPini::COPini()
{
}
COPini::~COPini()
{
}
void error(LPSTR lpszFunction)
{
CHAR szBuf[80];
DWORD dw = GetLastError();
sprintf(szBuf, "%s failed: GetLastError returned %u\n",
lpszFunction, dw);
MessageBox(NULL, szBuf, "Error", MB_OK);
ExitProcess(dw);
}
BOOL COPini::WriteString(LPCTSTR section, LPCTSTR key, char *stringtoadd, char *filename)
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,filename);
return ::WritePrivateProfileString(section,key,stringtoadd,FilePath);
}
DWORD COPini::ReadString(char *section, char * key, char stringtoread[], char * filename)
{
CHAR FilePath[255];
GetModuleFileName(NULL,FilePath,255);
(strrchr(FilePath,'\\'))[1] = 0;
strcat(FilePath,filename);
return ::GetPrivateProfileString(section, key,NULL,stringtoread,255,FilePath);
}
you can it like this:
#include <<OPini.h>>
int main()
{
char *p1 = "Hello";
char *p2 ;
COPini::WriteString("Section1", "KeyName1", p1, "SetInfo.ini");
COPini::ReadString("Section2" , "KeyName2", p2, "SetInfo.ini");
.....
}
Good Luck !
modified on Tuesday, May 4, 2010 6:29 AM
|
|
|
|
|
How does this help to create a non-existent folder structure? I think that SHCreateDirectoryEx() would be a better choice.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I have some code that is not getting executed in release mode. The code is in appui3.cpp in microsofts library. The method is GetProfileInt. I am trying to read some prefereces from the registry. It is working in debug mode, but in release it doesn't seem to be going to the method therefore I am not getting expected data. I am compiling with the /ZI switch for debug info in release mode also. Using VS2008. Any ideas?
Thanks
Ray
|
|
|
|
|
You could try by disabling optimizations.
For reading data from the registry use the registry functions instead.
|
|
|
|
|
Yes I have disabled the optimization. Thanks for the input, but why is it still not executing this part of the code?
Ray
|
|
|
|
|
Ok, I have decided that the code is getting executed, its just that when I step through in release mode it doesn't show me the actual steps it is taking nor are the value of the variables in the debugger valid.
So back to my problem that prompted this message. My program gets an exception in release mode but not in debug, but if I can't step through the program or rely on the debug variables in release mode, then how do I find out what is causing the exception? I've turning on the debugging information /Zi, turned off optimization, and turned on generate debug info in the linker. Still can get no usefull info from the debugger in release mode. Any ideas?
Ray
|
|
|
|
|
Step through the code and see...
Steve
|
|
|
|
|
Since you have the source code, you can make a backup of it and then modify this file to help you debug. Use OutputDebugString() and the free dbgview from sysinternals.com (now MS). This works for release mode build.
|
|
|
|
|
My problem is that it never goes to this code in release mode. I've put a break point on it and it never hits it.
|
|
|
|
|