Results 1 to 8 of 8
  1. #1
    killer121561's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    351
    Reputation
    8
    Thanks
    52
    My Mood
    Relaxed

    I need help with this project

    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


    Your Either Nexus Or Your Against Us

  2. #2
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Quote Originally Posted by killer121561 View Post
    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
    You just want to read the first ASCII character in a text file?

  3. #3
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Code:
    ifstream f;
    f.open("freedompeace.txt");
    f >> buf;

  4. #4
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Code:
    #include <fstream>
    using namespace std;
    
    char getfirstcharfromfile()
    {
    	ifstream thefilestream;
    	thefilestream.open ("thefilename.txt");
    	char *output;
    	thefilestream >> output;
    	return output[0];
    }

  5. #5
    killer121561's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    351
    Reputation
    8
    Thanks
    52
    My Mood
    Relaxed
    thanks every one i needed that


    Your Either Nexus Or Your Against Us

  6. #6
    -Dimensions-'s Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    243
    Reputation
    2
    Thanks
    161
    My Mood
    Aggressive
    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 );
    }

  7. The Following User Says Thank You to -Dimensions- For This Useful Post:

    killer121561 (08-02-2011)

  8. #7
    killer121561's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    351
    Reputation
    8
    Thanks
    52
    My Mood
    Relaxed
    awesome thanks for the help @-Dimensions-


    Your Either Nexus Or Your Against Us

  9. #8
    yodaliketaco's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Location
    winsock.dll
    Posts
    646
    Reputation
    45
    Thanks
    511
    My Mood
    Tired
    Quote Originally Posted by yodaliketaco View Post
    Code:
    #include <fstream>
    using namespace std;
    
    char getfirstcharfromfile()
    {
    	ifstream thefilestream;
    	thefilestream.open ("thefilename.txt");
    	char *output;
    	thefilestream >> output;
    	return output[0];
    }
    I should correct myself. I was a little tired when I wrote this.

    Code:
    #include <fstream>
    using namespace std;
    
    char getfirstcharfromfile()
    {
    	ifstream thefilestream("thefilename.txt");
            char out = thefilestream.get();
            thefilestream.close();
    	return out;
    }

Similar Threads

  1. [Help] i need help with this hacks....
    By idomix in forum Combat Arms Europe Hacks
    Replies: 2
    Last Post: 12-19-2009, 10:10 AM
  2. [Help] Need help with this game
    By holvis in forum Soldier Front General
    Replies: 1
    Last Post: 12-06-2009, 07:41 AM
  3. OPK need help with this .
    By lalobon in forum Combat Arms Hacks & Cheats
    Replies: 11
    Last Post: 08-24-2009, 02:11 AM
  4. I need help with this code in C#
    By trevor206 in forum Programming Tutorial Requests
    Replies: 0
    Last Post: 08-18-2009, 06:40 PM
  5. Need help with this error...
    By Screenlooker in forum Combat Arms Hacks & Cheats
    Replies: 6
    Last Post: 12-27-2008, 03:21 PM