|
Hey,
This is how you can do it in C++:
#include <fstream>
#include <vector>
int main() {
std::ifstream fin("test.txt");
fin >> std::skipws;
std::vector<int> test;
int j;
while (fin >> j)
test.push_back(j);
return 0;
}
Hope that helps you.
--
Henrik Stuart (http://www.unprompted.com/hstuart/)
|
|
|
|
|
Good Soultion, Thanks. I learn something new every day just reading these posts...
John
|
|
|
|
|
Try this using fscanf()
FILE *fopen( "Yourfile" );<br />
int nIn = 0;<br />
while ( fscanf( fp, "%d ", &nIn ) == 1 )<br />
{<br />
}<br />
fclose( fp );<br />
Note the space following the %d.
Personally I prefer to read text files line-by-line using fgets(), and then parse each line but as long as there are no bogies in the data, the above should work fine.
|
|
|
|
|
I appreciate the swift responses. They are very helpful. Many thanks to all of you for helping,
ns
|
|
|
|
|
Hey, how are you? And happy birthday, my dear!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
And to you too! Getting a little old there eh? Not me....I'm just a youngster....haha!
My computer died on me....so only have one machine today...aaargh. I'm taking a course on data structures (at the local univ but online). Its fun! In the middle of a project for solving mazes with depth first search. My son graduated from bootcamp last week....we had 15 degrees in Chicago! Fun city though...
Gotta call polywell now for my athlon......yaaaargh! Later!
|
|
|
|
|
ns wrote:
Not me....I'm just a youngster
'Tis the only way to be!
ns wrote:
My son graduated from bootcamp last week
Congratulations!
ns wrote:
solving mazes with depth first search.
Brings back fond memories! Check out Data Structures + Algorithms = Programs (by Nicklaus Wirth). Dated, but still a good book. Wirth is the co-inventor if Pascal. I met him in Zurich in 1987 at the ETH. Really nice guy!
ns wrote:
we had 15 degrees in Chicago
Toasty warm compared to what Boston's been getting!
Have a swell year!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Not virtual memory but physical memory does a machine have. Does anyone know the name of an API that will return the amount of physical memory?
thanks
|
|
|
|
|
check GlobalMemoryStatus , GlobalMemoryStatusEx
|
|
|
|
|
See this thread.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
|
hi there,
i need to process some stuff every time my cwnd obj gets scrolled. the problem is that onvscroll is not called if one scrolls with the wheel.
can somebody help me please?
Я люблю русский языкь!
|
|
|
|
|
Try processing the WM_MOUSEWHEEL message.
onwards and upwards...
|
|
|
|
|
Hello, I'm going to code an own small kernel, but I have a problem concerning the compiler to use.
I want to use Microsoft compilers, but there is the problem, that these compiler always what to create PE files, and I need a binary file with a base address of 0x00000000.
The GCC compiler supports this by using the command "-ffreestanding".
Is there any equivalent for Microsoft compilers or any other way using Microsoft compilers to do this?
Thank you for your attention.
Alexander M.
Don't try it, just do it!
|
|
|
|
|
You will get PE format only if you are building a win32 application, naturally you dont want win32, you want a .COM type application whose memory model will be TINY. that will not have any far calls and no .exe header,
Tried looking for tiny option in msdn but could not find it.
You can i suppose use the VC IDE and use gcc compiler to do the compilation by using custom build.
hope i helped in some way.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
thanks
Don't try it, just do it!
|
|
|
|
|
i want to get the handle of a clicked window among various opened windows;
when i click any opened window i want to ge the handle of it
Hawk,amr
|
|
|
|
|
WindowFromPoint(...) Gives you the handle of the window that was clicked.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
I have variables x&y which is manipiulated & read across some functions. Ok the pseudo code looks like -
void func1() {
enter critical section
manipulate x & y
leave critical section
}
void func2() {
read x
enter critical section
manipulate x & y
leave critical section
}
void func3() {
enter critical section
manipulate x & y
leave critical section
}
Ok the above code crashes in func2 at "read x". func1, func2 & func3 are in a multithreaded environment access
Will it be a good practice to define a new critical section for variable x or there is a simpler way to tackle this ? It shud be efficient
Dimple
|
|
|
|
|
Whats harm in reading the data also in the critical section in func2?
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
ok it is a producer consumer problem
func3 is producing something which func2 is using but before using it i need to check the value of x.
I am using critical section only as of now. How do i add this notify thing ...
Dimple
|
|
|
|
|
You should read x outside of critical section only if the operation read x is atomic, i.e. it is guaranteed by the OS or hardware, that the reading will never be interrupted.
Generally, if x is a complex data type, there isn't any suitable atomic read operation. So you should enclose read x in a critical section too. It avoids you from a conflict, when one thread reads x and another thread writes to x simultaneously (so the reading thread could read inconsistent content of x )
Robert-Antonio
It's a good luck, when you meet a real fink. Then you get a respect to
normal, mid-honest people."
|
|
|
|
|
Ok it func3 writes data & func2 reads data
If data has been written it is refelected by x (a int value) so thats the reason i read x.
Simply put i want to know how to do a conditonal wait on x
|
|
|
|
|
I think it would be ok to use mutexes to synchronize things.
You could use WaitForSingleObject(MutexName, INFINITE) before reading or writing to x, then call ReleaseMutex(MutexName) after the process.
This would synchronize things. But be sure to put then in the right place, this might cause deadlocks if misused.
Hope this help. :>
SDE
|
|
|
|
|
Hi all,
Is there any way to get the IDocHostUIHandler from the IWebBrowser2 inteface pointer.I want to disable the context menu in IE all version?.
I am using BHOs which host the Iwebbrowser interface pointer.
thanks in advance
Abhi Lahare.
|
|
|
|