Thread: another pointer question....

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    29

    Question another pointer question....

    i've got a question... i want to make a REAL small scripting language by using a void * vector. i would like to know if this code is safe (causing memory leaks maybe?) and if there is any disadvantage for creating variables on the heap only.
    also, i would like to know what you think about it.
    here is my code:
    Code:
    vector<void *> pointers;
    cout<<"Enter a type and a name"<<endl;
    cout<<"Example: int a, string d"<<endl;
    cin.getline(var,100);
    vars=var;
    for(int l=0;l<vars.length();l++){
    if(vars.substr(l,1)==" "){
    pos=l;
    }
    }
    if(type=="int"){
    pointers.push_back(new int);
    cout<<"Value:";cout.flush();
    cin>>(*((int*)pointers[i]));
    cout<<*((int*)pointers[i])<<endl;
    i++;
    }
    
    anyways, thanks for any replay
    Last edited by gftmc; 08-14-2006 at 03:57 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. Easy pointer question
    By Edo in forum C++ Programming
    Replies: 3
    Last Post: 01-19-2009, 10:54 AM
  3. char pointer to pointer question
    By Salt Shaker in forum C Programming
    Replies: 3
    Last Post: 01-10-2009, 11:59 AM
  4. Pointer question
    By rakan in forum C++ Programming
    Replies: 2
    Last Post: 11-19-2006, 02:23 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM