|
Only very occasionally. I'm doing penance for my dumb question in the Database forum yesterday.
|
|
|
|
|
In C++, you can only have one main.
The standard explicitly says in 3.6.1:
A program shall contain a global function called main,
hich is the designated start of the program.
[...] This function shall not be overloaded.
You can have two functions called main. The name is not special in any way and it's not reserved.
What's special is the function, and it happens to have that name. The function is global.
So if you write a main function in some other namespace, you will have a second main function.
namespace secondMain
{
int main() { return 0; }
}
int main()
{
secondMain::main();
}
The first main function is not special - notice how you have to return explicitly.
|
|
|
|
|
However, the OP code is C , you know, another programming language.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hello guys,
I have a problem. I'm writing to a log file, but when I do the application throws:
An unhandled exception of type 'System.AccessViolationException' occurred in ****
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
The code (unmanaged) I'm using is this one:
inline bool writeLog(nsCLog::eSeverity severity, string message)
{
ofstream myfile;
if( ((int)severity) >= mLogLevel)
{
myfile.open(mStrSource.c_str(), ios::in | ios::out | ios::app);
if(!myfile.is_open())
{
throw "Unable to open the file: " + mStrSource;
}
myfile << "TESTE" << endl;
myfile.close();
}
}
return true;
};
When receiving this error, the code points to the _Lock() of file fstream:
virtual void __CLR_OR_THIS_CALL _Lock()
{ if (_Myfile)
_CSTD _lock_file(_Myfile);
}
Other info:
Developed under VS2010 (Incially the project was Winx32 but now it's Winx64) (.NET Framework 4).
The open() method of ofstream creates the file and the file is writable but throws the exception when try's to write on the file.
Thank you guys in advanced.
modified 1-Aug-14 12:23pm.
|
|
|
|
|
Just for curiosity: why are you throwing a string and catching a bad_alloc ?
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Hello,
It's a typo
I'm going to remove it.
Thanks
|
|
|
|
|
You are welcome.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Ok guys,
For future notice, the problem was related to the configuration of the project. When I converted the project from .net 3.5 to .net 4 and from x32 to x64 something didn't quite go right.
So I reverted everything back and converted again in a more controlled environment and now i can open/write/close files without a problem.
Cya
|
|
|
|
|
Hello,
How you fixed the access violation error on Visual Studio 2010. I am trying to write data to csv file but it is giving me access violation error. As you mentioned, the debugger points to :
virtual void __CLR_OR_THIS_CALL _Lock()
{ // lock file instead of stream buffer
if (_Myfile)
_CSTD _lock_file(_Myfile);
}
|
|
|
|
|
I have a VC++/MFC application.This was in ancient code, visual studio 6. While compiling it in VS2010 it gave tons of errors and required changes in settings. I got good guidance from http://www.codeproject.com/Members/Jochen-Arndt.
Now my project is compiling/linking and .exe file is also launching.
While the application is running since output is in Japanese so in English OS it shows all junk characters.
Now i take the whole code base to Japanese windows OS, compile the code and run the application there,
Why do I still see the junk characters on application dialogue boxes/captions/ Labels ?
Any area you can hint I can look into display caption/labels/dialogue box in Japanese ?
Please help.
|
|
|
|
|
The obvious question: have you selected Japanese font into the application's resources?
|
|
|
|
|
Obvious answer...that's why its showing Junk characters in the english OS.
modified 31-Jul-14 6:04am.
|
|
|
|
|
Can someone point me to some C++ or C# examples on how to loop thru a group of similar CSV files and import them to an access db? Thanks.
|
|
|
|
|
|
Hi,
I am working on a project which requires to use a web service in C++ native application. I have searched on the net and found many links which explains that it is possible using C++ REST SDK. I have downloaded and installed the C++ REST SDK for visual studio 2010 but couldn't find any sample application using REST SDK to call a web service.
Can anyone help me regarding this. How to use a web service in C++ using REST SDK.
Regards,
mba
|
|
|
|
|
|
I have recently written a 'project browser' ctrl for my hobby ide BUT when i right click on an item to 'select item and show menu' even though the carat is on the new item the control reports the active TREEVIEWITEM is the previously selected item and the menu acts on the prev selected item.
With listboxes its easy you just subclass the ctrl and simulate "press lmb down and lmb up" when rmb is pressed but this method doesnt work at all with treeviews.
How do i select a item with the rmb?
Ps. you can be technical with your responce, im v.familiar w/ winapi.
thx bob
Sorry guys lol. Just solved it. You use the TVM_HITTEST to get the current item under the mouse cursor then call TVM_SELECTITEM w/ that item.
Then call trackpopupmenu as normal.
4 hours wasted last night on that one... still happy ending.
modified 30-Jul-14 6:30am.
|
|
|
|
|
What messages or notifications are you responding to?
|
|
|
|
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
float summation(float g);
int main(int argc,int *argv[])
{
srand(12345);
float z;
float a=0.2,y=0.0;
int i;
for(i=0;i<5;i++)
{
float b=((float)rand()/(float)(RAND_MAX))*a;
printf("%f\n",b);
z=summation(b);
}
printf("summation:\n%f\n",z);
return 0;
}
float summation(float g)
{
int i;
float y[5],sum =0.0;
float c=0.0;
for(i=1;i<5;i++)
{
float z=y[i]-c;
float t = sum+z;
c=(t-sum)-z;
sum=t;
return sum;
}
}
output
0.035679
0.079935
0.033320
0.042424
0.012387
summation:
0.000000
|
|
|
|
|
Your summation function makes no sense. You pass in a parameter which is ignored and then do some fairly random calculations, and return the value which will be zero, after a single iteration of the loop.
|
|
|
|
|
so as far as u say which way i should proceed?
actually my logic was not working so was planning to implement kahan summation.
|
|
|
|
|
maibam debina wrote: so as far as u say which way i should proceed? Well the first thing you need to do is to define what the summation function is supposed to do; I cannot make any sense out of it. Once you have done that, then define the steps required and convert them to code. It would probably help you immensely to use meaningful names for your variables rather than single letters which make it difficult to understand.
|
|
|
|
|
can u please help me out with code...
|
|
|
|
|
Well I could, but i) I have no idea what your summation function is supposed to do, and ii) you would learn more by trying it yourself.
|
|
|
|
|
Actually the logic which i use to implement for performing the summation was
<blockquote class="quote"><div class="op">Quote:</div>for(i=0;i<5;i++)
{
float f= ((float)rand()/(float)(RAND_MAX))*a;
y=square(f);
sum +=y;
}
printf("\n Summation Of Square Number is:=%f\t\n",sum); </blockquote>
but it doesnot seem well its not giving the exact summation value,all i want was to perform summation of the generated float random numbers .
|
|
|
|