Like Tree1Likes
  • 1 Post By phantomotap

urgent help required.

This is a discussion on urgent help required. within the C++ Programming forums, part of the General Programming Boards category; We have been given a project where we have to make a c++ code generator through a give text file. ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    2

    urgent help required.

    We have been given a project where we have to make a c++ code generator through a give text file.
    I'm attaching a file, please look at it and give some idea on how can this be done. I will be really grateful. Looking for a prompt response. Thank you.
    help.txt

  2. #2
    Registered User
    Join Date
    Apr 2011
    Posts
    2
    This is what i've come up with yet, and I know it is incorrect because if you change the parameters in the sample input, the output goes all wrong.


    Code:
    #include <fstream.h>
    void main ()
    {
    	char CLASS[50];
    	ifstream fin;
    	fin.open("sample_input.txt");
    	fin.getline(CLASS, 20, '\n');
    	ofstream fout;
    	fout.open("code.txt");
    	fout<<"#include <iostream>"<<"\n";
    	fout<<"using namespace std;"<<"\n";
    	fout<<CLASS<<endl;
    	fout<<"{"<<endl;
    	fin.seekg(27);
    	fin.getline(CLASS, 50, ')');
    	fout<<CLASS<<":"<<endl;
    	fin.seekg(51);
    	fin.getline(CLASS, 10, ')');
    	fout<<CLASS;
    	fin.seekg(40);
    	fin.getline(CLASS, 20, '(');
    	fout<<CLASS<<";"<<endl;
    	fin.seekg(51);
    	fin.getline(CLASS, 20, ')');
    	fout<<CLASS;
    	fin.seekg(60);
    	fin.getline(CLASS, 10, '(');
    	fout<<CLASS<<";"<<endl;
    	fin.seekg(83);
    	fin.getline(CLASS, 10, ')');
    	fout<<CLASS;
    	fin.seekg(78);
    	fin.getline(CLASS, 10, '(');
    	fout<<CLASS<<";"<<endl;
    	cout<<fin.tellg();
    	fin.close();
    	fout.close();
    
    }

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,171
    I love it! No longer are teachers simply teaching bad design techniques from the start; they are teaching people how to automatically produce code with bad design techniques.

    GENIUS!




    To the original poster, first write the program yourself from the template, then figure out the steps you took to get there, and finally, you need to automate those steps.

    Out of curiosity, are you supposed to use memory allocation, or just ........ away all semblance of good design?

    Soma
    Elysia likes this.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    2,514
    This project is much like an Code Generator for a UML Diagram; C++ is possible but not really the best Language to process text files.

    Tim S.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help required urgent!!
    By ikj in forum C++ Programming
    Replies: 2
    Last Post: 05-28-2009, 10:15 AM
  2. Urgent Help required.. pls help ??
    By intruder in forum Windows Programming
    Replies: 2
    Last Post: 01-10-2003, 12:05 PM
  3. urgent help required
    By Nadia in forum C Programming
    Replies: 4
    Last Post: 12-10-2002, 05:10 AM
  4. Urgent help required
    By sweets in forum C++ Programming
    Replies: 3
    Last Post: 05-03-2002, 01:17 PM
  5. Embedded SQL - urgent help required!
    By Robg in forum C Programming
    Replies: 1
    Last Post: 10-13-2001, 12:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21