|
#include "StdAfx.h"
#include <iostream>
#include <string>
int main()
{
using namespace std;
string line;
if (getline(cin, line))
{
cout << "Line read was \"" << line << "\"" << endl;
}
return 0;
}
Steve
|
|
|
|
|
Hi thanks for the reply
Well in the code you mentioned you never opened any file.So what line is it reading.
Or here you hv just nt included dt as you giving example .
Well actually problem is that i have tried so many programs by now...but none of them are opening the file. I dont know where am i going wrong....just now i tested 3-4 different programs but same it doesnt open the file...I am real stucked here..i ll try with your code by adding
std::ifstream InFile( "data.txt" );...dont knw if it gonna work or not...
Thanks
|
|
|
|
|
The sample I gave reads from the standard input stream; the file used is the console or a file if input redirection is used. To use a file specific file use code like this:
#include "StdAfx.h"
#include <iostream>
#include <fstream>
#include <string>
int main()
{
using namespace std;
ifstream file("C:\\File.txt");
if (!file)
{
cerr << "Failed to open input file!" << endl;
return 1;
}
unsigned int count = 0;
string line;
while (getline(file, line))
{
cout << "Line " << ++count << ": " << line << endl;
}
return 0;
}
Steve
|
|
|
|
|
this is really strange...even this is not opening file.
I created file named File.txt under C folder as you mentioned the path.
and with data as
abc,def,ghi
jkl,mno
pqr
stu,vw,xyz
But its not even opening the file. Reading the file is the next step. It should first open the file atleast....
Oh its giving me a heading now.
Thanks for your reply
|
|
|
|
|
The code I posted was also tested and worked for me. Nothing fancy is going on so I can't see why it doesn't work for you. Can you post the exact code you're using?
Steve
|
|
|
|
|
Hi
just now i tested it here at work and its working fine . I dont know whats wrong in my pc. May be my OS is not allowing it to read the file.
Can you think of any problem related to this.
Well i really need to sort this out at ma laptop. I wasted hell lotta time over this and the problem was something else. huh..
And yeh cn you also mention the command to hold the screen for output.
Well i am trying out with stystem("pause"); but it isnt working .
Is there any thing else for this.
Thanks a lot..
|
|
|
|
|
Software_Specialist wrote: I dont know whats wrong in my pc. May be my OS is not allowing it to read the file.
Can you think of any problem related to this.
Perhaps it's a security issue.
Software_Specialist wrote: And yeh cn you also mention the command to hold the screen for output.
I assume you're building a console app. One option is to use the Sleep function. e.g. Sleep(1000); to suspend the calling thread for one second. This function is in <windows.h> . Another option is to call _getch from <conio.h> to wait for a key press.
Steve
|
|
|
|
|
Hi All,
Looking for something that I hope is simple! Is there an index of "tmpstr" numbers that relate to the pocket pc platform, for reference to certain bits of info within the registry?
Example: To extract the Email Address that is entered in the device owner setup in the device, I would use (tmpStr[283])
or for the Phone Number within the owner setup (tmpStr[258])
I'm looking to extract the "Notes" info from
HKEY_CURRENT_USER\ControlPanel\Owner
Is there a master tmpstr index of numbers for this? Or can someone at least tell me what the value is for "Notes"
Thanks in advance, and sorry for my nubie approach!
BTW: Trying to program in evc++ 4.0
ZapMe1
|
|
|
|
|
How to get the active interfaces from the system. i am having both LAN and wirelss adapters but the lan is unplugged. how to get the active adapters in mfc
-- modified at 16:58 Saturday 24th March, 2007
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
What do you mean by "active"?
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Hello,
My question is this.
How can I count the number of lines of code of my project?
I use Visual Studio.Is there any option?
Thanks
|
|
|
|
|
There are plug ins you can download, there is nothing build in
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
No, because I don't know what version you're using of visual studio. But, you know, and google will be happy to help you when you give it that info.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Visual Studio 2005
Yes,but what r the key words?
|
|
|
|
|
Someone shoot me.
Did you try searching code project for "line count" ?
http://www.codeproject.com/useritems/LineCounterAddin.asp[^]
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian, Christian. Turn the gun around and shoot him. Feel better now? I thought you would.
Software Zen: delete this;
|
|
|
|
|
Come on guys dont be so bad...
|
|
|
|
|
hi everyone,
i'm in desperate need of a code that prints the content of the screen in OpenGL/C++
if anyone has a code or links that can help..i'll be greatful..
u can send me the links/code on my mail..karim.samir@hotmail.com
thanks,
karim
|
|
|
|
|
I'm using the MS Chart Control in Visual C++.net. I'm trying to change my chart type from 2dBar to 2dLine, programically. I can't find out how to do it - the documentation is just horrible. Can anybody help me!!!
I've tried ->chartType=, but I don't kow what to set the chart type equal to?
THANKS!!!
Kim
|
|
|
|
|
There is a great sample project here:
www.codeproject.com/listctrl/xlistctrl.asp
I can run the executable (anyone can do that) but I have had no
luck in compiling any of the projects. I get a variety of different
errors from unicode to
Cannot open include file: 'uxtheme.h':
Any chance any one can help me compile a smaller project
of a listctrl without Unicode and without the file
visualstylesxp.h? Im trying to find a listctrl that lets the
user edit individual cells and this project can do it. I just
cant get it to work.
Please, please, any response any one can give me will be greatly
appreciated.
My email address is brinasas@yahoo.com
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
You can probably strip themes from the code. Otherwise, you need to download a platform SDK to get these headers. If you're using VC6, then you'll have more issues, as the newer PSDKs do not support it ( and you should stop using it, if you can )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How about this? I put together a smaller sample project that has
an older version of XListCtrl built in. The one feature I seek, which
is the new release, is the ability to edit cells directly. That code is
in this file XEdit.cpp/.h; any chance I can email you this smaller sample
project and you can somehow make the XEdit work so that I can edit text
in cells?
Please, please, please, please!!
My email address is brinasas@yahoo.com
Sincerely,
Danielle Brina
|
|
|
|
|
I'd recommend going to www.araxis.com and downloading a trial version of their merging tool, that will let you diff the two files ( old and new ) and hopefully quickly see what code needs to be copied across to make that work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
I want to save clipboard content with any format it may have and load it back again.
I'd be glad if someone could help me with this.
|
|
|
|