Loading
August 20, 2014, 10:34:57 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: Please help me i am going crazy lol  (Read 827 times)
brianatwa07
Newbie
*
Posts: 22


« on: February 23, 2011, 09:10:25 PM »

        ok heres what i got, i have a variable called "cardname1" and i saved that variable to a txt file like we did in lesson 47. then in a differant function() i displayed, the card name. and that all worked really good but here is what i wanna do with it. after i display the name back onto the consloe window i want to use it as a VARIABLE again. ii dont wanna just display the cardname but i wanna use it as a variable. someone please help me.     thank you.


  ifstream qfile("dept.txt");
    string qline;

   
    while(!qfile.eof()){

    getline(qfile,qline);
    // here is where i would like this to go back into a varable
      }

    cout << cardname1;
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 961



« Reply #1 on: February 23, 2011, 09:40:08 PM »

If you read the value into a variable, then you should have it until the variable falls out of scope. My guess is that is the problem. You should try to declare it in a larger scope. If there's any confusion about that, you should watch our lesson on scope.

http://xoax.net/comp/cpp/console/Lesson11.php

Mike
Logged
brianatwa07
Newbie
*
Posts: 22


« Reply #2 on: February 23, 2011, 09:46:39 PM »

would scope matter if i completly close the program then reopen it, would the variables still be there.
Logged
brianatwa07
Newbie
*
Posts: 22


« Reply #3 on: February 23, 2011, 10:30:59 PM »

      you are right thanks so much your amazing. it was the scope!
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!