Thread: Encoding and coding text.

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    8

    Encoding and coding text.

    I have to write a program like this, but i'm not that good. Please someone help me

    Created file in notepad, to open and read and to make statistic for letter number(how many lettes), numbers and punctuation marks, control marks and empty spaces.

    The text in the file should be encoded by the rule: encoding and decoding to be done with two diferent functions.
    Key of coding: in the text to encode only the letters from the alphabet and the numbers. Every letter in the string, which is odd position to be replaced with the letter who is two places after the replacing letter in the alphabet. The last letters Y,Z to be replaced with A,B consequently. Steam letters in the string do not suffer any changes.
    Odd letters numbers to be replaced with steam numbers who are their followers and odd numbers to be replaced with their steam predecessors. 9 to encode 0 and 0 with 9.
    Control marks and punctuation marks do not suffer any changes.
    Treated like this file to be saved under a different name and be called decode.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    What do you mean, "i'm not that good"? Noone is untill he/she tries to be better!
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    8
    im not that good to write this code, i need help

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by dzadze View Post
    im not that good to write this code, i need help
    You need to show some effort first!
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    278
    No One is going to write this for you. He checks into the forum on Thursdays. Usually.

    Meantime, why not try the parts you DO understand? You know, just in case.

    Create the notepad file.
    Then write some 'c' that opens it
    Then make your 'c' read some of it in.
    Then read all of it in.
    Then open a new file and write to it.

    Step by step.

  6. #6
    Registered User
    Join Date
    May 2011
    Posts
    8
    i'll try..
    when i stuck on something i'll post here

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    278
    Quote Originally Posted by dzadze View Post
    i'll try..
    when i stuck on something i'll post here
    Exactly. Be sure you post it in CODE tags (read the forum FAQ) and make sure it's compilable (complete) - not just random snippets.

  8. #8
    Registered User
    Join Date
    May 2011
    Posts
    8
    here's something i've made, but how to make statistic how many letters and numbers are the file ?
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <stdio.h>
    #include <fstream>
    #include <string>
    
    using namespace std;
    int main(){
    ifstream in;
    string x;
    int i, b=0;
    in.open("C:\\test.txt");
    while(getline(in,x))
    cout<<x<<endl;
    cout<<endl;
    for(i=0;i<in.length();i++){
    if(in.at(int(i))>=65 && in.at(int(i))<=90 && in.at(int(i)>=97 && in.at(int(i)<=122)
    b++;
                                 }
    cout<<"The file has"<<b<<"letters"<<endl;
    vlez.close();
    system ("PAUSE");
    return EXIT_SUCCESS;
    }

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    That's C++, not C. I'm not sure what you mean by making them static; even static variables are going to be destroyed when the program ends.


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User
    Join Date
    May 2011
    Posts
    8
    i am stuck.. do u know how to count the numbers and the letters from the file ?

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    That's C++, not C. I'm not sure what you mean by making them static; even static variables are going to be destroyed when the program ends.
    Quzah.
    Clean your glasses son! He said "statistic" ... not "static".

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Clean your glasses son! He said "statistic" ... not "static".
    Good catch, but I'm not sure that makes any more sense.


    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    Good catch, but I'm not sure that makes any more sense.
    Quzah.
    Oh you know... count characters, words, digits, spaces, lines, cows in the field across the road... that sort of thing.


  14. #14
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by dzadze View Post
    here's something i've made, but how to make statistic how many letters and numbers are the file ?
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <stdio.h>
    #include <fstream>
    #include <string>
    
    using namespace std;
    int main(){
    ifstream in;
    string x;
    int i, b=0;
    in.open("C:\\test.txt");
    while(getline(in,x))
    cout<<x<<endl;
    cout<<endl;
    for(i=0;i<in.length();i++){
    if(in.at(int(i))>=65 && in.at(int(i))<=90 && in.at(int(i)>=97 && in.at(int(i)<=122)
    b++;
                                 }
    cout<<"The file has"<<b<<"letters"<<endl;
    vlez.close();
    system ("PAUSE");
    return EXIT_SUCCESS;
    }
    Your indentation is crap. You didn't even make an effort. Your parentheses don't even match on your if statement. You'll never get statistics (or statics) working if you can't even compile a simple program to read a file. God only knows what vlez is. And, as Quzah pointed out, you're doing C++, not C. I'm not sure you really want to pass this class, or that you really want our help.

  15. #15
    Registered User
    Join Date
    May 2011
    Posts
    8
    i am a total noob,
    vlez=in, forgot to change that

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading from a text file into an array and coding.
    By tombocollbo in forum C Programming
    Replies: 6
    Last Post: 12-09-2010, 01:25 PM
  2. Characters encoding
    By guillermoh in forum C Programming
    Replies: 4
    Last Post: 02-05-2008, 09:36 PM
  3. Character Encoding
    By bithub in forum Windows Programming
    Replies: 3
    Last Post: 01-07-2006, 01:39 AM
  4. URL Encoding
    By nickname_changed in forum C# Programming
    Replies: 2
    Last Post: 03-13-2004, 03:22 AM
  5. Encoding
    By gvector1 in forum C# Programming
    Replies: 0
    Last Post: 06-20-2003, 10:17 AM