|
Hello,
I find thant CRichEditCtrl's stream (in/out) method can Read (write) text
quickly, and it support large *.txt document.
but I want to tranlate the text to my string array.
now the problem is : how can I translate between EditStream and string array
thanks
|
|
|
|
|
Hi guys i want to write a module which process user name and password.It's console software But i don't know how to hide the password when typing in the console like ********.If anyone know how to do this pls tell me......
Thanks in Advance
|
|
|
|
|
You could try using _getch[^] to read up the characters yourself and simply output astericks or whatever. Or maybe you could try redirecting stdout for the time of the password entry, don't know how that would work though.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
What Code-o-mat told will work for you. Here is the code snippet.
char strPasswrd[100];
int i = -1;
do
{
strPasswrd[++i] = _getch();
cout<<'*';
}
while(strPasswrd[i] != '\r');
strPasswrd[i] = '\0';
cout<<endl;
cout<<strPasswrd;
|
|
|
|
|
Hi Cool_Dev your code is very helpful to me but the problem is it also print one * for '\r' also
|
|
|
|
|
couldn't you re-write it as..
char strPasswrd[100];
int i = -1;
strPasswrd[++i] = _getch();
while(strPasswrd[i] != '\r')
{
cout<<'*';
strPasswrd[++i] = _getch();
}
strPasswrd[i] = '\0';
|
|
|
|
|
Hello,
I wanted to move the implementation of some of my functions to a DLL and update only the DLL and do not touch the GUI.I normally use STL and i learnt that STL and DLLs together can create some problems. Lets say i have such a function below and that Point3D vector will be given from another DLL (which deals IO stuff).
1. DLL
TEST_API double calcPerimeter(const std::vector<Point3D>& pts)
{
double p = 0.0;
for(std::size_t i = 1; i < pts.size(); ++i)
p+= calcDistance(pts[i-1],pts[i], false);
p = sqrt(p);
return p;
}
2. DLL
i want to export a std::vector<point3d> from a function.
Will this work or even if it works under what conditions? By the way, I will use the same compiler for exe and dlls.
How will you implement above? (a very simple data holder (Point3D vector) in a DLL and in another DLL just bunch of functions which operates on that data?
Best Regards.
Bekir.
|
|
|
|
|
Provided you use the same compiler and probably linker, the same compiler and linker settings (with a few exceptions to do with building DLLs) then you can do what you want without any problems. The fun comes with DLLs when people wonder why they can't link C++ DLLs with EXEs written in C or on another C++ compiler.
Cheers,
Ash
|
|
|
|
|
Additional to what Aescleal wrote, do not use STL across library boundaries if you can avoid it! Unfortunately, it's not guaranteed to be binary compatible and can cause you troubles in the long run. Nasty things can happen when you mix compilers or STL versions, hard to debug.
Cheers
|
|
|
|
|
Thank you for the answers.
I will look at options to remove that STL vector, any recommendations ?
Bekir.
|
|
|
|
|
I hate to say it, but in this case use only fundamental/primitive types and pointers. For example use as arguments buffer and buffer size/elements, avoid unnecessary data copying, e.g. caller provides buffers big enough to hold results.
You gave a function using STL, here is a slight variation of it:
TEST_API double calcPerimeter(const Point3D* pPoints, int nElements)
/M
|
|
|
|
|
Hi Moak,
I was about to write that function and ask and saw your message.
When I use, then i can safely give the vector's first element as reference to the function and vector's size.
std::vector<Point3D> points;
....
if(!points.empty())
calcPerimeter(&points[0], static_cast<int>(points.size());
Best Regards.
Bekir.
|
|
|
|
|
There's another option here which probably means changing your design...
From the small amount of code you've posted it looks to me like you're trying to handle 3D paths of some sort. Instead of exposing a set of functions which operate on vectors of points, how about defining an interface?
class path
{
public:
virtual ~path();
virtual double length() const = 0;
virtual double distance_from( const point &p ) const = 0;
};
Then you can write all your client code that deals with paths in terms of that interface. You can then impelement paths in your DLL or pass them into other DLLs and not have to worry about copying, assignment and all the other DLLy problems (such as exporting functions - THIS is the big plus for me...).
So say you implement a concrete path in your DLL:
class vector_path : public path
{
public:
vector_path( const std::vector<point *> &points_defining_path );
~vector_path();
virtual double length() const;
virtual double distance_from( const point &p ) const;
private:
std::vector<point *> points_defining_path_;
};
you can export a pair of creation/deletion functions:
PATH_EXPORT path *create_vector_path( const point **start_pts_in_path, const point **end_pts_in_path )
{
std::vector<point *> pts_in_path( start_pts_in_path, end_pts_in_path );
return new (no_throw) vector_path( pts_in_path );
}
PATH_EXPORT void cleanup_path( path *to_cleanup )
{
delete to_cleanup;
}
This gives you a nice interface you can use without worrying about lobbing vectors around as you're dealing with paths, a much higher level concept.
Cheers,
Ash
|
|
|
|
|
Dear Ash,
Thank you for such a detailed answer, at first i thought i can have data set and implement different operations on that data set (Area, Perimeter and some clipping operations)
Defining an interface and hide the data in concrete classes and use interface functions to operate on is another perhaps better way. I had already looked into below link. Mature Approach part is similar to yours except virtual destructor is replaced by a Release() method and Smart Pointer calls that function for clean-up.
HowTo: Export C++ classes from a DLL[^]
Again thank you for the answers.
Best Regards.
|
|
|
|
|
If you go for that style of solution there's plenty you could do to improve the safety of the solution I outlined - private destructor, cleanup function a friend of the interface so it can be deleted, quick typedef for shared_ptr and a helper to create them. If you need some more help with the details please ask another question and I can bore you further!
Cheers,
Ash
|
|
|
|
|
Which one takes more processing time a. contineous if condition or switch case in while loop .
e.g.
while(conditon)
{
switch(conditon)
{
case contion :
}
codition++
}
or
if(condition)
{
}
if(condition)
{}
if(codition)
{}....
and so ono...
Thanks
|
|
|
|
|
No idea and even if I could give you an idea it'd only be for the compiler (including settings) I tested it on and running the code on the particular configuration of computer/OS I ran it on. If you really want to know then about all you can do is test it on the computer the code's eventually going to run on.
Cheers,
Ash
|
|
|
|
|
|
Hi sir,
I have origin axis and x1,x2,y1,y2.
I want to draw a rectangle and rotate it with the given degree.I am trying with this code,but i am not getting.
Her is the code
double x1,x2,y1,y2;
sf=(1024/31);
A1 = 10.00;
A2 = 10.00;
B1 = 10.00;
B2 = 10.00;
x1 = (A1 * sf);
x2 = (A2 * sf);
y1 = (B1 * sf);
y2 = (B2 * sf);
float Angle = 45.0;
x1 = x1 * cos(Angle) + y1 * sin(Angle);
y1 = -x1 * sin(Angle) + y1 * cos(Angle);
x2 = x2 * cos(Angle) + y2 * sin(Angle);
y2 = -x2 * sin(Angle) + y2 * cos(Angle);
Origin(525,454);
MoveToEx(pCellInfo->hDC,center.x-x1,center.y-y2,NULL);
LineTo(pCellInfo->hDC,center.x-x1,center.y+y1);
LineTo(pCellInfo->hDC,center.x+x2,center.y+y1);
LineTo(pCellInfo->hDC,center.x+x2,center.y-y2);
LineTo(pCellInfo->hDC,center.x-x1,center.y-y2);
If i test with this hard code values,i am getting the rectangle rotated
MoveToEx(pCellInfo->hDC,525,289,NULL);
LineTo(pCellInfo->hDC,360,454);
LineTo(pCellInfo->hDC,525,619);
LineTo(pCellInfo->hDC,690,454);
LineTo(pCellInfo->hDC,525,289);
how can i get the same values
Thanks
Raj
Can some one help me
|
|
|
|
|
I can see a few problems straight up:
1. [Probably not important] If sf is an int, then that's probably not what you want.
2. Trig functions expect angles in radians not degrees, so an angle of 45.0 is probably not what you want.
3. Where is center being set? It could be some wild value so that all the drawing is offscreen. Look at the actual values you are passing to MoveToEx and LineTo.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Peter_in_2780 wrote: Look at the actual values you are passing to MoveToEx and LineTo.
Peter_in_2780 wrote: If sf is an int
No its double.
Peter_in_2780 wrote: Trig functions expect angles in radians not degrees,
I have changed it to
int a = 45;
float Angle = ( 3.142 * a ) / 180;
Peter_in_2780 wrote: Where is center being set?
I am gettin g the center by calculating the bitmag as..
center.x=(((pCellInfo->rcBitmapRect.right-pCellInfo->rcBitmapRect.left)/2)+pCellInfo->rcBitmapRect.left);
center.y=(((pCellInfo->rcBitmapRect.bottom-pCellInfo->rcBitmapRect.top)/2)+pCellInfo->rcBitmapRect.top);
Thanks
Raj
|
|
|
|
|
#include <iostream>
#include <windows.h>
using std::cin;
using std::cout;
using std::endl;
void main()
{
WIN32_FIND_DATA FileDetails;
HANDLE ListDirectory;
ListDirectory = FindFirstFile(L"C:\\*", &FileDetails);
cout << FileDetails.cFileName << endl;
FindClose(ListDirectory);
}
I read on MSDN the code is deprecated on Windows 7! Any ideas why it is giving me junk text as a result.
Does anyone also know a 1 line fix for the 3 using declarations?
|
|
|
|
|
Your code seems unicode, thats why cout prints junk.
use unicode version as wcout<<FileDetails.cFileName<<endl;
|
|
|
|
|
The using keyword is used as follows -
#include <iostream>
using namespace std;
|
|
|
|
|
It's only used that way if you want to dump the whole of the std:: namespace into your code. You can also use it on individual identifiers (as the original poster did) and to change the visibility of class members.
Ash
|
|
|
|