|
See here and here for starters.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to read a .txt file by my program, how can i do this? I have columns in my notepad file for e.g.
CUST. NO. X Y
0 71 69
1 53 57
3 69 12
4 58 12
5 63 45
6 25 109
7 100 81
8 .. ..
9 .. ..
10 .. ..
11
these are the 3 columns i have i.e. CUST. NO., X, and Y in my notepad file and i want my program to read it. The Cust No might go to thousands, means i dunno how much will it be. Also tell me what should i use to store these values or colums? simple arrays or linked lists or anything else?
Kindly help me in this regard by helping me in source code, ill be very thankful to u. Take care.
nOmI
|
|
|
|
|
nomi khan wrote: Kindly help me in this regard by helping me in source code,
What source code? What have you tried so far (that doesn't work)?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Open the file as a std::ifstream .
When the ifstream is good, you can use getline to read the file line by line, and normal std::string function to parse each line.
Evilgrin
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
You can use of CFile class.
|
|
|
|
|
you can use CStdiofile for reading line by line. and can read the column values by space separator( as u shown here )
Define ur columns in a structure and use CArray for storing these values.
Ajay
|
|
|
|
|
aks. wrote: Define ur columns in a structure and use CArray for storing these values
tThe solution is fine. but i have little doubt over usage of CArray. i like stl class much then MFC colection class. cince data coming is in form of string. we could use more specialized container i.e. CStringArray!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
u want to use stl? then u can use list
if u want to use CStringArray , then u have to store whole strings on a line to the array as one entry. on getting the values from CStringArray , u have to parse it for getting each vales of the column.
Ajay
|
|
|
|
|
Hi - I'm lost in an IO Network stream error -
because of something wrong in the socket -
and I can't figure out how to get the
WSA socket error associated with the IO error.
Is the error in the socket structure or
is there a function that will help me ????
Please help,,,,,,,,
|
|
|
|
|
Something like WSAGetLastError()
|
|
|
|
|
yes, I need something like that -
but - not running on server -
don't have all the right libs & dll's,
and header files - so - I was thinking
that there could be a function, perhaps
in the socket that would get that last
error ????????????????????
or somewhere ??????????
or should I just try & get ahold of
all the DLL, LIBs, & h files /?????/
|
|
|
|
|
There's no functions "in the socket".
What DO you have to work with? How are you debugging
without DLL, Libs, and h files?
You think an error is occurring on the server and you're debugging
from a client?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote:
You need more than one of these, Mark, as I've no clue what he wants either.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I didn't want to waste them....it's looking like I may need a lot of
them elsewhere
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have no experience with your situation or I have no idea what you are saying.
|
|
|
|
|
Hi people,
I’m having a problem while updating a CFormView. I switch a variable m_nStatus and depending on its value I do some things. My problems are in these lines:
case 4:
if (m_bWriteMode && !m_bReadMode)
m_cbTransfer.ShowWindow (TRUE);
else if (!m_bWriteMode && m_bReadMode)
m_cbRead.ShowWindow (TRUE);
break;
I know the problem is there, because if I comment them, all works ok.
What happens is that, when I have my application running on the top, works fine. If I switch to another program (i.e. back to VC++ to debug something) and come back, or using a timer all ok until the first WM_TIMER…
Then the FormView gets crazy and starts to update itself continuously, so quick, that the labels don’t appear. It stays so… till I move the window or something like that.
I guess that the ShowWindow () to make the buttons in/visibles is sending an internal UpdateWindow () or something like that. And it comes into a loop: show button, updatewindow, show button, updatewindow…
Is there any way to avoid this f… continous window update? I know I can make both buttons visible and play with the enable/disable, but I would like to do it as I have (without the problem of course).
Thanks
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Why are you showing/hiding controls in the view's OnDraw() method? Why not do that wherever m_bWriteMode or m_bReadMode changes?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The process is the same for both modes. I have to ensure 3 points before making a connection (status 3 = connection allowed), do the connection (status 4) and then, depending on what the user wants to do (write / read) allow only one of them.
My boss wanted to have it like that because of "pretty appearance".
So he said to do it with changing button depending on job-mode and suggested me to do that.
I have thought 2 alternative possibilities. Just 2 buttons and enable/disable them as with the others (it gives no problems) or one button changing caption depending on write/read and with the functionality inside separated in two ifs. I will most probably use the second one (1 button with two captions / functions) to follow the "desires" of my boss.
But I asked it because of the flickering. I know that it is due to ShowWindow, but I don't know why. I guess an internal invalidate/updatewindow to make the control visible or not, am I right?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: My boss wanted...
So why is he not doing the coding? His solution is obviously not going to work, so you are going to have to go against the grain and code it up correctly. When shown the final result, he'll hopefully forget about initially leading you astray.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
"So why is he not doing the coding?"
I think it comes in the definition of "boss".
"His solution is obviously not going to work"
For that reason I have implemented the 2nd solution above (1 button / 2 caption/functions), I follow his apearance-desires and I have good results as well. He is not going to see the code as long it makes what he wanted to see.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
OnDraw is called in response to a WM_PAINT message, which Windows generates when the message queue is otherwise empty and the window has an invalid region. Showing and hiding child windows will invalidate those areas of the window and cause OnDraw to be called again.
Some controls do make a nested call to UpdateWindow on themselves when their content is changed, but normally InvalidateRect is used alone to defer painting until the thread is otherwise idle.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
That is exactly what I wanted to know, thanks. I was guessing that, but didn't know the correct answer.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
If i had a green object, and a red spot-light, i'd expect to see a yellowish area where the light shines right?
Or if i had a light that was orange (R=255, G=200, B=0) everyhing would have an orange tint, (or if the object was pure white, actually go orange)
Instead, on my green cube, when i shine a red light on it, it doesn't light up unless the light is shining directly on to the surface, and then all i get is a red patch because of the specular highlights.
So, what can i do about it?
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
The Undefeated wrote: So, what can i do about it?
several things. First light is not light as you see it in the real world. Virtual lighting is a calculation of a direction vector of the light. Without other algorithms, it doesn't even have shadows and you can illuminate anything facing the light, even if it is behind something else obscuring the light.
Without adjusting anything else the entire face of your triangle has one directional surface, the normal vector. That vector determines how light reacts to the surface. Since a single vector exists for the entire surface, the entre surface will calculate the same lighting value. You can specify your own surface normals, in which you want one normal for each vertex rather than one for each triangle. So a triangle now has three surface normals of slightly different variation. The result is smoother light.
If you want more accurate light, you are looking for real-time global illumination, or radiosity on a GPU.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I already have a wonderfully illuminated rotating green cube, lit by a white spotlight, within a white/grey room. And am already aware of various techniques for creating shadows, and the need for normal vectors to ensure that the light acts they way you expect it. I wanted to know if i could blend the colour of the light, and the surface material.
Though i do appreciate the reply, and was unaware that i could supply a normal for each vertex to aid with smoother lighting.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|