I am having a problem in knowing where to start with my project that has to ask a user to enter a string of characters.. you can limit the size of characters and u decript those characters u can print them backward or u can change them into numbers depends on how u wana do it.... so what I have to do is to ask the user to enter these characters using files and and keep the string of characters on my "*.txt" and print them backward or numbers but I dont know how to go on about that

p.s I have to have 2 ccp files... one for output and one for input.... I have thought about substr() but Im not sure if that is gona work... please guys help me out

Recommended Answers

All 10 Replies

What in particular are you having difficulty with? What functions to put in which files? How to include the files so they can be called by main? What libraries to use? How to write the functions themselves? How to call them? What?

MMMM......... ok.....Let me post an example of what Im looking for although what I had to do is defferent from this one.....

As I said I have to prompt a user to enter the character it can be any size.... after that I have to take what the user has entered to a .txt file and output it backwards or as in numbers that is changing characters to numbers or printing characters backwards (e.g) A can be 1, B = 2 n so forth or U can have something like this... Traicey = Yeciart... now I need to have 2 cpp files.. 1. is encripting the data which the user has entered (i.e) printing it backwards or printing numbers.... 2. Is asking the user to enter the string and keep it to a .txt file.....so that means I am going to have cpp file which is InFile and another cpp file which is outfile, can call them Encription and Decription....

Yeah, I got all of that, you stated that the first time. I understand what the program is supposed to do. What I don't know and what I was asking the last time is what do you know how to do and what do you not? What have you done already and what are you stuck on? Do you know how to #include a file? Have you written the function headers? If you know how to do all of this and already have a skeleton of the two files and need help within the specific functions, post the skeleton.

Ouch!!!!!! I didnt do that 'coz I cudnt but I will try and the moment I finish with it I will post it ok.... The thing is.... I hate this Dev-C++, It does not give me anything in return... I mean Im coding to get the output at the end right!!!! but it just flashes and dissappear and its killing me!!!!!!

I am looking for something like this but it does not do a thing....

#include <iostream>
#include <fstream>
#include <string>
 using namespace std;

 int main (int argc, char *argv[])
 {
	 fstream In_Encr;
	 
	 In_Encr.open("Encription.txt");

	 string Name;
	 cout << "Enter you name:   ";
	 cin >> Name;
	 cout << endl;

	 cout << Name.substr(20, 1);
	 cout << Name.substr(10, 20);
	 cout << Name.substr(15, 1);
	 cout << Name.substr(1, 5);
	 cout << Name.substr(2, 12);
	 cout << Name.substr(4, 7);
	 cout << Name.substr(12, 5) << endl;
	 cout << endl;
	 
	 cin.get();
	 return 0;
 }

//Thats another ccp file

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
 using namespace std;

int main (int argc, char *argv[])
{
  ofstream out_data;
  out_data.open("Encription.txt");
  
  string name;
  out_data << "Your name is:  " << name << endl;  
  cin.get();
  return 0;
}

this will read in a name (which may contain spaces) and write it out to a file. fill in the TODO: part

#include <iostream>
#include <string>
#include <fstream>

int main()
{
  std::string name ;
  std::getline( std::cin, name ) ;
  
  // TODO:
  // add code here to transform each char in name 
  // eg. a => 1, b => 2 etc.

  std::ofstream file( "Encription.txt" ) ;
  file << name << '\n' ;
}

see if you can get this much done correctly.

once this is done, it would be time to look at the second program (which reads the file and displays the original name). don't even think about how you would do that right now. get this part to work first.

Im on it right now... thanx a lot ....Ur such a life savour

What does this means (a => 1) or '=>'

> What does this means (a => 1) or '=>'
it means a compile-time error in C++; there is no such operator.
what i intended was: convert each character in the string name to something else as required by your encryption logic. as an example, convert the character 'a' in the string name to a character '1' (before writing it into the file). a => 1 meaning transform character 'a' to character '1'.

LOL!!!!!
Ok..... I thought I shud ask because I have seen the operators in almost every programming languages but I never see such as that one except here and I alwayz thought that maybe is C language or whatever language that I neva get to do or see

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.