Thread: ignorent noob pls help with some i/o

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    3

    ignorent noob pls help with some i/o

    ok im new and this is my first post, so pls don't flame, i also did a search on this but came up with nothing, so here it goes:

    i am trying to make a very simple program to do some math and print it out into a text file, i want this text file to include a picture, i came up with two ideas to deal with this;

    1. use the i/o to put the picture in.

    2. have the picture in a preformatted text file, then have the user type in the name that they want the new file to be called, then use the ios::app command to add the text.

    in case 1. i don't know how to add the pic.
    in case 2. i don't know how to rename the file.

    any (postive) comments would be appeciated, thx for ur time

  2. #2
    Registered User
    Join Date
    Mar 2006
    Posts
    4
    Not sure I understand. You can't put pictures in text files, they're big binary objects. If you mean like an HTML page, the text just holds a link to the image file.

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    3
    yea srry bout that i thought i could save an image in a txt file for some reason...(im really tire...)

    any way i am working in a dos window with all this code... would i be able to add a jpeg( or similar) to that? if so how

    thx for the response

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    3
    this program is suppose to take info from the user and list out angles, lengths, etc. then i have a picture of a ramp with lengths labeled as their corrisponding letter


    here is the code:

    [tag]
    Code:
    /*
    |------------------------------|
    |  by:        |
    |  start date: Feb. 28, 2006   |
    |  Advanced Ramp Calc Program  |
    |  Version 1.01                |
    |------------------------------|
    */
    
    #include <iostream>
    
    #include <math.h>
    
    #include <fstream>
    
    #include <cstdio>
    
    using namespace std;
    
    int main ()
    {
      //creats all integers
      int n, a, b, c, d, z, width, flatlength, decklength, height, radius, flatheight;
      char name[15];
      float x, ramplft, ramplength;
     
     // creates loop
       while (n>0) {
             
             //names rtf file
             cout<<"what do u wish to call this file?"<<endl;
             cin.getline( name, 15 );
             
             //defines height
              cout << "height(in.): "<<endl;
              cin >> height;
              
              //defines ramp width
              cout<<"total width(in.): "<<endl;
              cin >> width;
      
              //defines radius
              cout<<"radius(in.): "<<endl;
              cin >> radius;
      
              //defines flat height
              cout<<"flat height(in.): "<<endl;
              cin >> flatheight;
      
              //defines flat length
              cout<<"flat length(in.): "<<endl;
              cin >> flatlength;
      
              //defines deck length
              cout<<"deck lenght(in.): "<<endl;
              cin >> decklength;
      
               //finds the length of z
               z = radius - height;
               //defines the z squared as b
               b = z * z;
               //defines the hypotonuse(radius) squared as c
               c = radius * radius; 
               // finds the length of x squared
               d = c - b;
               //defines the value of the bottom of the ramp
               x = sqrt(d);
               //shows total length of ramp
               ramplength = flatlength + decklength + x;
               //shows length of ramp in feet
               ramplft = ramplength / 12;
               cout<<"the ramp will be "<<ramplength<<" inches long, or "<<ramplft<<" feet long"<<endl;
               cout<<"A printable text file has been made and named as ramp.txt"<<endl;
      //Cand opens ramp.rtf
      ofstream a_file ( "ramp.rtf", ios::app );
      // Outputs to file through a_file
      a_file<< "(ft): "<<ramplft<<endl<<"w: "<<width<<endl<<"a: "<<x<<endl<<"d: "<<decklength<<endl<<"f: "<<flatlength<<endl<<"h: "<<height<<endl;
      // Close the file stream explicitly
      a_file.close();
               
               //starts loop over
               cout<<"Press any number to repeat: "<<endl;
               
      cin >> a;
      if (a == 1) {
               n = 1;
               }
      }
    
    cin.ignore();
    }
    [/tag]


    there is some extra stuff in there htat will be used later...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. asynchronized I/O == multiplexing I/O?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-24-2006, 10:06 AM
  2. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  3. Noob: needs help with file I/O
    By crws416 in forum C Programming
    Replies: 2
    Last Post: 03-06-2006, 09:35 AM
  4. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM
  5. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM