Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
Quick help needed
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 10-25-2009, 04:11 PM
Guru
 
Join Date: Jul 2007
Posts: 1,189
Send a message via MSN to mopar-user
Default Quick help needed

Ok, I'm making a game in C++. I'm using Dev C++ compiler. My issue deals with opening and close files.


heres an example of what i need...


I ask the user their name.
They input the name.
The name is assigned to a variable.

Now the hard part for me...

loadSave.open(This is where i want the variable for their name to be)

can't get it to work. I know it has something to do with .c_str() but i cant get it to work for the life of me. Help me please?
Reply With Quote
  #2  
Old 10-29-2009, 01:57 PM
d great one's Avatar
Apprentice
 
Join Date: Nov 2007
Posts: 930
Send a message via MSN to d great one Send a message via Yahoo to d great one
Default Re: Quick help needed

You mean you want to create a file using the name they input?
__________________
SCAMMERS ARE LOSERS. DO NOT BE ONE OF THEM
==========================
New: Buying all account upgrades + 4 vouches
==========================
I CAN MM FOR YOU - MM THREAD + MM VOUCHES || vouch(es) on this thread: 10
==========================
MY MSN: [email protected]
==========================
NOW SELLING RSGP || vouch(es) on this thread: 30
==========================
Account Shop || vouch(es) on this thread: 1
Lost thread: My buying + vouches thread || vouch(es) on this thread: 82
Reply With Quote
  #3  
Old 10-29-2009, 07:41 PM
Guru
 
Join Date: Jul 2007
Posts: 1,189
Send a message via MSN to mopar-user
Default Re: Quick help needed

Yes. Much easier said that way lol.
Reply With Quote
  #4  
Old 10-30-2009, 07:11 PM
d great one's Avatar
Apprentice
 
Join Date: Nov 2007
Posts: 930
Send a message via MSN to d great one Send a message via Yahoo to d great one
Default Re: Quick help needed

I don't really know the syntax in c++
but if you are just going to use their name as the file name.

Declare a variable for the file name and not the FILE creation variable.
Declare another variable that will hold their name.

In example...

string filename;
string name;
string ext=".txt"; // in example that you are going to make a .txt file

Ask for user name input

filename = name + ext; // I'm not sure if this is the correct format. I made a little searching and this is what I get (concatonate two strings in c++. but in c i know it is strcat(string1, string2); ) and you need the syntax for concat on two strings.

use the open file (with the file name as the variable filename)

and there you have it.
I hope I made my explanation understandable a little.
If not, why don't you put your code so maybe I can help you a little better.
Happy programming ^^
__________________
SCAMMERS ARE LOSERS. DO NOT BE ONE OF THEM
==========================
New: Buying all account upgrades + 4 vouches
==========================
I CAN MM FOR YOU - MM THREAD + MM VOUCHES || vouch(es) on this thread: 10
==========================
MY MSN: [email protected]
==========================
NOW SELLING RSGP || vouch(es) on this thread: 30
==========================
Account Shop || vouch(es) on this thread: 1
Lost thread: My buying + vouches thread || vouch(es) on this thread: 82
Reply With Quote
  #5  
Old 01-13-2010, 05:27 PM
Member
BANNED
 
Join Date: May 2006
Posts: 45
Default Re: Quick help needed

i'll write something for you. if you want a name for input. you use scanf();
then you'll need to declare an FILE pointer. and write a buffer from the input into the FILE.

Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char input[10]; // input buffer with a capicity of 9 character + 0 terminater.
    FILE *fp; // FILE datatype and a file pointer (FP).
    
    printf("Username please: ");
    scanf("%s",&input); // pointer to input. to store the input from the stdio
    printf("\n Your input is %s ",input);
    fp = fopen("C:\\username.txt","w+");
    fprintf(fp,input);
    fclose(fp);
        return 0;
}

Last edited by Eduard : 01-13-2010 at 05:32 PM. Reason: example
Reply With Quote
  #6  
Old 01-13-2010, 05:34 PM
Member
BANNED
 
Join Date: May 2006
Posts: 45
Default Re: Quick help needed

i'll write something for you. if you want a name for input. you use scanf();
then you'll need to declare an FILE pointer. and write a buffer from the input into the FILE.

Code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char input[10]; // input buffer with a capicity of 9 character + 0 terminater.
    FILE *fp; // FILE datatype and a file pointer (FP).
    
    printf("Username please: ");
    scanf("%s",&input); // pointer to input. to store the input from the stdio
    printf("\n Your input is %s ",input);
    fp = fopen("C:\\username.txt","w+");
    fprintf(fp,input);
    fclose(fp);
        return 0;
}
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 02:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1