Thread: interection with hard disk

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    Unhappy interection with hard disk

    please tell me how to interect with hard disk data area with the help of c language

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Your nearest C book should get you started. Other than that, consider reading the FAQ. Other than that, you'll have to make yourself clearer as to what it is you're trying to do, and where you're trying to do it.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    This is the API for opening and closing files, and accessing information in files.
    fopen
    fclose
    fread
    fwrite
    fgets
    fputs

    Anything else is deep voodoo, and you really ought to know what the hell you are doing unless you really enjoy doing fdisk, format c: and reinstalling operating systems.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    173
    Here's a simple program to help you see how it works, consult manuals for more functions as listed by Salem. Thing to look out for is checking what the file function returns, much like how you check for malloc() etc.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    const char* filename = "hello.txt";
    
    int main(int argc, char **argv)
    {
    	FILE* fp = fopen(filename,"w");
    	if (fp == NULL) {
    		fprintf(stderr,"Could not open!");
    		exit (EXIT_FAILURE);
    	}
    
    	fputs("Inserting some text into disk\n",fp);
    	fputs("And some more...\n",fp);
    
    
    	if (fclose(fp) != 0)
    	{
    		fprintf(stderr,"Could not close!");
    		exit (EXIT_FAILURE);
    	}
    
    	return 0;
    }

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > please tell me how to interect with hard disk data area with the help of c language
    Oh, and the aforementioned voodoo requires a lot more information from you like your OS and compiler.

    Not to mention things like root/admin priviledges.

    And some other stuff....
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debian on a system with Compact Flash, without Hard Disk
    By mynickmynick in forum Linux Programming
    Replies: 19
    Last Post: 09-01-2008, 11:38 AM
  2. hard disk serial number
    By vijayaroli in forum Windows Programming
    Replies: 1
    Last Post: 08-31-2006, 03:00 AM
  3. how to read hard disk serial number
    By toufiq_raja in forum C Programming
    Replies: 4
    Last Post: 08-18-2005, 10:08 PM
  4. Formatting Output
    By Aakash Datt in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2003, 08:20 PM
  5. Strange hard disk
    By GanglyLamb in forum Tech Board
    Replies: 20
    Last Post: 03-01-2003, 04:05 AM