I need help finding out how to read a txt file and turning it to a char.
I tried everything and i cant get it so please help
thanks
[IMG]https://i1188.photobucke*****m/albums/z410/killer121561/Nexus-1.jpg[/IMG]
Your Either Nexus Or Your Against Us
Code:ifstream f; f.open("freedompeace.txt"); f >> buf;
Code:#include <fstream> using namespace std; char getfirstcharfromfile() { ifstream thefilestream; thefilestream.open ("thefilename.txt"); char *output; thefilestream >> output; return output[0]; }
thanks every one i needed that
[IMG]https://i1188.photobucke*****m/albums/z410/killer121561/Nexus-1.jpg[/IMG]
Your Either Nexus Or Your Against Us
Code:/* Make sure you have all of them #include <d3d9.h> #include <d3dx9.h> #include <d3dx9core.h> #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string> //#include <time.h> #include <vector> #include <windows.h> #include <Winuser.h> */ using namespace std; void DrawFileText( LPDIRECT3DDEVICE9 pDevice, const char *dir, D3DCOLOR TextColor, float x, float y ) { if( !pDevice ) return; char txt[255]; std::ifstream inFile( dir ); if ( !inFile ) { this->PrintText( x, y, TextColor, "While opening a file an error was encountered!" ); } inFile.getline( txt, 255 ); std::cout<<txt; this->PrintText( x, y, TextColor, txt ); }
killer121561 (08-02-2011)
awesome thanks for the help @-Dimensions-
[IMG]https://i1188.photobucke*****m/albums/z410/killer121561/Nexus-1.jpg[/IMG]
Your Either Nexus Or Your Against Us