Results 1 to 18 of 18

Thread: is c++ alright for writing vhd files

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    is c++ alright for writing vhd files

    i have visual studio 6.0 if i buy c++ will it run with this and is there lots of people using it like vb6?
    thanks

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: is c++ alright for writing vhd files

    VS6.0 is a suite that contains several language in series like, VB6, VC++6, VF6, etc... Why do you need to buy it separate ?

    If you are moving to .Net, then try Visual Studio 2010. Or get the free Express versions of the languages from Microsoft's site.

    Or, if you are a student, you might get the free Pro versions of these languages via DreamSpark initiative of Microsoft.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: is c++ alright for writing vhd files

    I believe the OP wants to work with VHD files (virtual hard drives).
    Last edited by szlamany; May 9th, 2012 at 05:24 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: is c++ alright for writing vhd files

    Quote Originally Posted by szlamany View Post
    I believe the OP wants to work with VHD files (virtual hard drives).
    oops sorry !

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    never paid attention to the others time to start

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    ive been googling alot on how to make /create an vhd file ,what exactly do i look under to find more info?
    thanks

  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: is c++ alright for writing vhd files

    Just curious - you aren't trying to break into a VHD file - are you?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    nope.
    just strickly making one my self,i know theres tons of programs out there to do this ,i have some of them,just something i do to learn how it works and i like to do it myself , at least as much as i can...

  9. #9
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: is c++ alright for writing vhd files

    I searched up

    VHD FILE FORMAT

    This looks like a good link - with more links at the bottom

    http://www.enotes.com/topic/VHD_(file_format)

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    hey msdn says the api for Virtual Hard Disk have to be running win 7 can it still be used in win xp?

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    hi
    what does (cin) stand for?
    how do i put my name and age in without having to prompt the user?
    thanks

    Code:
      // prompt user to enter the new info  
      cout << "Set database info...\n";
      cout << "Name: ";
      cin.getline(per.name, 8);
      
      cout << "Age: ";
      (cin >> per.age).get();// add the .get() to clear the newline character
      
      cout << "Salary: ";
      (cin >> per.salary).get();// note .getline() clears its own newline character
    
      // save the new user-entered data  
      if (SaveDB(&per))
        cout << "\nDatabase saved!\n";
      else
        cout << "\nUnable to save database!\n";
    
      // give the user a chance to look things over before quitting
      cout << "\n[hit enter]";  
      cin.get();
    
      // return 0 on success (main() should never be void!)
      return 0;

  12. #12
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: is c++ alright for writing vhd files

    cin is for input operations(to read user inputs) and cout is for output operations(displaying on the screen)


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    Code:
    do i have to use (char) letters and (int) for numbers?
    
    
     
    // the data that will go into the database
    struct Person {
      char name[40];
      int age;
      float salary;
    };

  14. #14
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: is c++ alright for writing vhd files

    char is the datatype for storing character. Inorder to store a string, you would use an array of characters(a string would contain a number of characters. So we are using array of char to store strings)

    And int is to hold numbers within a specific range. It's of the range -32K to +32K I think. So you could store any values within that range in an int variable. Unsigned int would have a range of 0 to 64K. Just google it to know more.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    im getting an error at this line.
    Person Per ;{

    the error is
    Code:
     error C2447: '{' : missing function header (old-style formal list?)
    am i doing something wrong
    thanks
    Code:
    #include <fstream> // for ifstream, ofstream, ios_base
    #include <iostream>// for cin, cout, endl
    // you can just say `using namespace std;` here instead of all these 'using's
    using std::ios_base;
    using std::cout;
    using std::cin;
    using std::endl;
    
    // just creating a constant for the name of the database
    static const char *DATABASE_FILE = "pr1.bin";
    
    // the data that will go into the database
    struct Person {
    
      char name[8];
       int Features;
       int FFVersion;  
       int DataOffset;
       int TimeStamp;
      char CreatorApplication[4];
       int CreatorVersion;  
       int CreatorHostOS;
       int OriginalSize;
       int CurrentSize;
       int DiskGeometry;
       int DiskType;
       int Checksum;  
       int UniqueId;
       int SavedState;
       //int Reserved;
    
    };
    
    
    Person  Per ;{
    
    
    
        name = williamc;
        Features = 0000;
        FFVersion = 0100;  
        DataOffset = FFFFFFFF;
        TimeStamp = 1000;
        CreatorApplication = wmc ;
        CreatorVersion = 0100;  
        CreatorHostOS = Wi2k;
        OriginalSize = 5243392;
        CurrentSize = 5243392;
        DiskGeometry = 00065535;
        DiskType = 0002;
        Checksum = 0512;  
        UniqueId = 1234567812345678;
        SavedState = 1;
    }
    
    
    
    
    
    
    
    
    // this function takes a pointer to a Person struct
    // that will be filled with the data in the file
    bool LoadDB(Person *per) {
      // first parameter is the name of the file
      // second is the open flags. 
      //    `in` says you will read from the file
      //    `binary` says you will read binary data instead of simple text
      std::ifstream fin(DATABASE_FILE, ios_base::in | ios_base::binary);
      
      // if we couldn't open the file (it may not exist); fail
      if (!fin.is_open())
        return false;
      
      // the file is open; tell the read function to look at `per` as a
      // char pointer instead of a Person pointer so that `fin` can place
      // one byte at a time into the struct
      // the second parameter tells read() how many bytes to read
      // Note: do not use the ">>" operator to read from a binary file 
      fin.read((char*)per, sizeof(Person));
      fin.close();// close the file - not necessary, but we should be neat
    
      // success  
      return true;
    }
    
    // this function takes a pointer to a Person struct
    // that will be written into the file
    bool SaveDB(Person *per) {
      // these flags say:
      //    `out` - we will be writing data into the file
      //    `binary` - we will be writing binary data and not simple text
      //    `trunc` - if the file already exists, truncate (wipe out) the existing data
      std::ofstream fout(DATABASE_FILE, ios_base::out | ios_base::binary | ios_base::trunc);
      // couldn't open it (disk error?); fail
      if (!fout.is_open())
        return false;
    
      // notice this time we cast the Person pointer to a const char* because we aren't
      // altering the structure this time; rather we're just looking at it's contents.  
      fout.write((const char*)per, sizeof(Person));
      fout.close();// close the file - not necessary, but we should be neat
    
      // success  
      return true;
    }
    
    int main() {
      // create an empty person struct
      Person per;
       
      // load the data in the db file
      if (LoadDB(&per)) {
        // print what we loaded into our Person struct
        cout << "Loaded Database...\n";
        cout << "Name = " << per.name << endl;    
        cout << endl;
      }
       
     
      // save the new user-entered data  
      if (SaveDB(&per))
        cout << "\nDatabase saved!\n";
      else
        cout << "\nUnable to save database!\n";
    
      system("pause");
    
      // return 0 on success (main() should never be void!)
      return 0;
    }

  16. #16
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: is c++ alright for writing vhd files

    This

    Person Per ;{

    should be this

    Person Per {

    I would believe...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: is c++ alright for writing vhd files

    nope tried that .

    yall have a good mothers day


    thanks all

  18. #18
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: is c++ alright for writing vhd files

    Try accessing it's member's using the dot on the object.

    Example:
    c++ Code:
    1. Person  Per ;
    2.     Per.name = "williamc";
    3.     Per.Features = 0000;
    4.     Per.FFVersion = 0100;  
    5.     Per.DataOffset = FFFFFFFF;
    6.     //...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width