GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-May-2008, 15:12
Mrehman Mrehman is offline
New Member
 
Join Date: Mar 2008
Posts: 23
Mrehman is on a distinguished road
Question

how to convert a file to GIFT format


hey guyz what's up? i searched a lot on this topic but i juts can't seem to get it.
can any one tell me how to convert a .txt file to a GIFT format or convert a file GIFT format. what do you write in the program so the file is converted. please Thanks.
  #2  
Old 10-May-2008, 01:15
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 466
Peter_APIIT can only hope to improve

Re: how to convert a file to GIFT format


Are you talking about GID(Graphic Interchange Format) ?

GIF is 8 bits color.

I hope this help.
  #3  
Old 10-May-2008, 04:00
Mrehman Mrehman is offline
New Member
 
Join Date: Mar 2008
Posts: 23
Mrehman is on a distinguished road

Re: how to convert a file to GIFT format


no sorry. maybe my instruction from the file that i attached might help you to understand better because this is the first time i have even heard of this format.
Attached Files
File Type: doc CMSC_201_Project_2.doc (53.5 KB, 7 views)
  #4  
Old 10-May-2008, 09:33
J-M J-M is offline
New Member
 
Join Date: Apr 2008
Posts: 14
J-M is on a distinguished road

Re: how to convert a file to GIFT format


Hi,

so your assignment is to convert a txt file to different format. (gift-file format is desribed in the doc you provided.)
I don't know how much you have programmed before and how familiar you are with streams. So here is the program's structure described:

Code:
1. Open txt-file for reading (http://www.cplusplus.com/reference/iostream/ifstream/) 2. Check that it is opened. 3. Open gift-file for writing (http://www.cplusplus.com/reference/iostream/ofstream/) 4. Check that it is opened. 5. Read line from txt-file. (http://www.cplusplus.com/reference/string/getline.html) 6. Determine which type of line is it and convert it to gift-format. 7. Write converted line to gift-file. ( << ) 8. Continue from step 5 if txt-file has more lines. 9. Close txt-file. 10. Close gift-file.

BR,
J-M
  #5  
Old 10-May-2008, 13:03
Mrehman Mrehman is offline
New Member
 
Join Date: Mar 2008
Posts: 23
Mrehman is on a distinguished road

Re: how to convert a file to GIFT format


thanks bu ti got that part. this is so far i am able to do. i am able to take my file and write it on a different file name.
here's my code
CPP / C++ / C Code:
# include <iostream>
# include <string>
# include <stdlib.h>
# include <stdio.h>
# include <fstream>

using namespace std;

void ConvertFile (ifstream &infile, ostream &outfile);

void main()
{
	char inFileName[100], outFileName[100];
	ifstream infile;
	ofstream outfile;

	cout << "Input file: ";
	cin >> inFileName;
	cout << "Output file: ";
	cin >> outFileName;

	infile.open(inFileName, ios_base::in);
	if(infile.fail())
	{
		cout << "The file did not open successfully" << endl;
		exit(1);
	}

	outfile.open(outFileName);
	if(outfile.fail())
	{
		cout << "The file did not open successfully" << endl;
		exit(1);
	}

	ConvertFile(infile, outfile);
	infile.close();
	outfile.close();
}

void ConvertFile(ifstream &infile, ostream &outfile)
{
	while(!(infile.eof())) 
	{
		char line[500];
		infile.getline(line, 500, '\n');
		outfile << line << endl;
	}

}
now what i don't get is that how do i convert it to GIFT format. i know i can use void displayfile to display a certain file. but what do i use to convert a txt file to GIFT format. you get it. the file i am using is attached.
Attached Files
File Type: txt tf.txt (22.6 KB, 2 views)
  #6  
Old 10-May-2008, 13:44
J-M J-M is offline
New Member
 
Join Date: Apr 2008
Posts: 14
J-M is on a distinguished road

Re: how to convert a file to GIFT format


Hi,

please use string instead of char array.
string has c_str()-method which you can use with fstreams.

GIFT format is exlained in the doc provided, first example shows that:
Code:
Grant is buried in Grant's tomb. False
converts to
Code:
Grant is buried in Grant's tomb.{F}
Question remains the same as stated, but answer is wrapped insade curly braces "{}", so first line of the attached file
Code:
1. To discard an old computer safely, put it in a landfill. F
first there is question number "1." which is discarded as shown in diagram on the first page. So this line is corverted to
Code:
To discard an old computer safely, put it in a landfill.{F}

When you parse line and convert it to GIFT format, in T/F questions you can find first letter of the line and from that search "." or "?", between them is the question and after that is the answer.
  #7  
Old 10-May-2008, 17:02
Mrehman Mrehman is offline
New Member
 
Join Date: Mar 2008
Posts: 23
Mrehman is on a distinguished road

Re: how to convert a file to GIFT format


thanks i figured that out right after i posted my previous post.but thanks though
 
 

Recent GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Airport Log program using 3D linked List : problem reading from file batrsau C Programming Language 11 29-Feb-2008 07:44
After execution - Error cannot locate /Skin File? WSCH C++ Forum 1 05-Mar-2005 20:03
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 11:28
Can't view pages from another machine on the Intranet aevans Apache Web Server Forum 9 14-May-2004 02:26
CD Buring Failed skanth2000 Computer Hardware Forum 1 15-Nov-2003 03:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 05:53.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.