|
kbhit() and delay() are DOS (16-bit real mode) functions that are only exist in the libraries for the old Borland C++ (not Borland C++Builder) compilers. That free compiler you're using is the same compiler used in certain versions of C++Builder, so it only builds Win32 programs, not 16-bit real-mode programs.
If you really want the use the free Borland compiler, you'll have to write a Win32 Console-Mode program (I don't know how you would specify that mode with the free compiler). You would use the Win32 function Sleep() in place of delay() , and you'd need to access the parallel port's I/O ports using a DLL to allow 32-bit protected-mode access. The most common one seems to be inpout.dll from http://www.logix4u.net/[^]
|
|
|
|
|
Whew - thanks for answering that one. I'd forgotten about sleep() , so I would have had to do some searching!
|
|
|
|
|
i have a character buffer.
char buffer[]="VisualC++";
then i want to split a space between them it goes to
char buffer[]="Visual C++"
, how i can do that??
HelpMe
|
|
|
|
|
C and as far as I know C++ do not have "insert into string" functions. You have to write this sort of thing yourself. The steps below may guide you.
Create a character newBuffer[20] (bigger than your original buffer)
Copy 5 characters from buffer[0] to newBuffer[0] (the memcpy() function may be suitable.)
Put a space in newBuffer[6]
Copy 3 characters from buffer[6] to newBuffer[7]
Write a null terminator in newBuffer[10]
You now have the updated string in newBuffer.
If you want it in variable buffer, you have a problem, because the compiler will not have allocated enough space for it. Since you created it by char buffer[]="VisualC++" , the compiler will allocate 10 bytes for variable buffer - 9 characters plus terminating zero. As a result, buffer does not have room for 10 characters plus terminating zero.
|
|
|
|
|
Hello everyone!
Alright... I'm following the instructions from this site:
http://gpwiki.org/index.php/SDL:Tutorials:Practical_Keyboard_Input[^]
Here's my code:
render();<br />
<br />
SDL_Event event;<br />
while (SDL_PollEvent(&event))<br />
{<br />
switch (event.type)<br />
{<br />
case SDL_KEYDOWN:<br />
switch (event.key.keysym.sym)<br />
{<br />
case SDLK_UP:<br />
yVel = -CSIZE;<br />
break;<br />
case SDLK_DOWN:<br />
yVel = CSIZE;<br />
break;<br />
case SDLK_LEFT:<br />
xVel = -CSIZE;<br />
break;<br />
case SDLK_RIGHT:<br />
xVel = CSIZE;<br />
break;<br />
}<br />
break;<br />
case SDL_KEYUP:<br />
switch (event.key.keysym.sym)<br />
{<br />
case (SDLK_ESCAPE):<br />
case SDL_QUIT:<br />
return 0;<br />
break;<br />
case (SDLK_UP):<br />
yVel = 0;<br />
break;<br />
case (SDLK_DOWN):<br />
yVel = 0;<br />
break;<br />
case (SDLK_LEFT):<br />
xVel = 0;<br />
break;<br />
case (SDLK_RIGHT):<br />
xVel = 0;<br />
break;<br />
}<br />
break;<br />
}<br />
<br />
int temp_x = xPos + xVel;<br />
int temp_y = yPos + yVel;<br />
<br />
if ((temp_x > -1) && (temp_x < WIDTH)) xPos += xVel;<br />
if ((temp_y > -1) && (temp_y < HEIGHT)) yPos += yVel;
I can't find the problem! The dude only moves 1 spot even if I keep the arrow pressed... Anyone know? Thanks!
BTW: I'm on Linux!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 19:25 Wednesday 15th March, 2006
|
|
|
|
|
Hello,
I am running a simple C console application in VS.net. I want to be able to measure the run time between certain lines of code, and also the time required to run the entire application, etc. Are there any tools/libraries that I can add to my program to do this? Will the debugger allow me to do some of this?
:}
Jerry
|
|
|
|
|
In the viual studio there is menu called profie. it can be used for finding the time taken by entire application, time spend in each function etc.
check http://www.codersource.net/win32_Debugging_VC.html[^]
Simply if u want to find the time taken for a single/group of statement, put OutputDebugString() before and after that statement. Then using the debug viewer u can get the time..
nave
|
|
|
|
|
Hi all,
I must say how useful I find the help offered here. Although sometimes it takes a while to get a response, the wait nullified by some mouthwatering suggestions.
Anyway let me get down to my question. I want to display the time and date (from my system clock or local clock) in a text box inside a Dialog box. Any suggestions?
Regards,
luhfluh
|
|
|
|
|
|
|
COleDateTime t = COleDateTime::GetCurrentTime();
CString str = t.Format(_T("%A, %B %d, %Y"));
m_edit.SetWindowText(str); For more information on format flags used in Format look here[^]
Nibu thomas
Software Developer
|
|
|
|
|
Using Michael Dunn's method you can ensure that the date is formatted as per the setting in the users locale.
Steve
|
|
|
|
|
Hi, when i first tried the above code on a new empty project, it worked without any problems.(after including the ATLComTime.h)
But i finally modify and use it in my intended solution and i have 4 errors and 4 warnings:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(246) : warning C4935: assembly access specifier modified from 'public'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(258) : warning C4935: assembly access specifier modified from 'public'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7408) : error C2872: 'IDataObject' : ambiguous symbol
could be 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(246) : System::Windows::Forms::IDataObject IDataObject'
or 'stdafx.cpp(0) : System::Windows::Forms::IDataObject'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7422) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Form1.cpp
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(246) : warning C4935: assembly access specifier modified from 'public'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(258) : warning C4935: assembly access specifier modified from 'public'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7408) : error C2872: 'IDataObject' : ambiguous symbol
could be 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(246) : System::Windows::Forms::IDataObject IDataObject'
or 'stdafx.cpp(0) : System::Windows::Forms::IDataObject'
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7422) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
Can you figure out what I might nid to do? Tks
|
|
|
|
|
Thanks y'all,
I tried the various ways and i'm glad with the results.
Regards...
|
|
|
|
|
How to pick-up a specal word from a string ?
I like to interrogate words from line by line from a file.
How to pick-up numerical numbers from a mixture of letters and numerics ?
|
|
|
|
|
I have found using Regular Expressions to be very useful in doing this. You can find Regular Expressions implementations in Microsoft's ATL and the Boost Library (http://www.boost.org). They are a little hard to learn but worth the effort.
|
|
|
|
|
Thanks.
Do you have any code segments for reference ?
Thanks
|
|
|
|
|
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main(int argc, char* argv[])
{
regex e("The .*");
if ( regex_match("The quick brown fox jumps over the lazy dog!", e) )
{
cout << "Match!" << endl;
}
return 0;
}
Steve
|
|
|
|
|
|
I met link error when using DLL. I created the DLL and corresponding lib in Visual studio 2005, and parts of codes are in c not c++, and I did not include "extern "C"" in building dll. As I used DLL and lib in the application, error message occured:
error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl voidtry(int)" (__imp_?voidtry@@YAXH@Z) referenced in function _main
Because in creating DLL, some c codes are used, I do not know whether I should use "extern "C"" declaration to those export function. Another thing is that in building DLL, those export functions are dependent on some functions in c code, should I add "__declspec(dllexport)" to those c code functions? Thanks for your help.
|
|
|
|
|
I don't have answer to your question. But if you suspect that by using extern "C" it might work then why not try it?
-Saurabh
|
|
|
|
|
I think that you may forget to add your lib name to the project as additional library. or you forget to set the dependence of project when you develop application and DLL in the same solution.
//////////////////////////////////////////////
maybe right , maybe wrong
|
|
|
|
|
Thanks for your suggestion. I added the DLL and Lib in the application program directory, also I used the code "#pragma comment(lib, "aacresample.lib")" to include the lib. When build the program, I copied other c files, and head files in my directory, so I did not set dependence of project. BTW, I rebuilt the lib adding "extern "C"" declaration. But I still got the same link error.
|
|
|
|
|
It looks odd to me that VC++ .NET 2005 adds a new function to a different cpp file.
I have a folder (named as Dialogs) which stores a bunch of header and cpp files of dialogs in a project (MyApp) folder. When I right click mouse in Class View to add a new function to MyDialog class whose header and cpp files are in Dialogs folder within MyApp folder and click OK, Visual Studio automatically adds the definition of the function to the correct header file, however, it adds the function implentation codes to a new cpp file right in the MyApp folder instead of MyDialog with the same name of the class. In order to have VS correctly place the codes to the cpp file under Dialogs folder, I have to specified the location of cpp file in the Add-member-function-wizard. This means that every time I want to add a function to a class whose cpp file in NOT directly under the default project folder (MyApp in this case), I have to explicitly specify location of its cpp file . This is annoying and is NOT the behavior of VS 6.0.
Anyone knows a way to fix this or this is the way VS .NET 2005 is?
|
|
|
|
|
ofstream f_ptr2;
string qq;
while (....)
{
f_ptr2.write(qq.c_str(),qq.length());
}
I found the above code continueously write in one big line. How to write a new line each
time when while repeat ?
|
|
|
|