how to partition hard drive linux stackoverflow

C++
    $ sudo fdisk /dev/sdb -l

    Disk /dev/sdb: 250.1 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0002da94

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1   *        2048   475920383   237959168   83  Linux
    /dev/sdb2       475922430   488396799     6237185    5  Extended
    /dev/sdb5       475922432   488396799     6237184   82  Linux swap / Solaris
mount /dev/sdb1 /mnt/usb

Source

Also in C++: