need help on rewriting

This is a discussion on need help on rewriting within the C Programming forums, part of the General Programming Boards category; Hi everyone ... i have a request : i have a source code that one of my friends gave me ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    6

    need help on rewriting

    Hi everyone ... i have a request :
    i have a source code that one of my friends gave me ...
    I need to re write this in a way that the outcome be similar to the original one (little differences are acceptable ) but the commands and the lines that are written be different from the original one ...
    since I have little knowledge in c++ can somebody write this for me please
    *sorry about my english it's not my native language*
    Code:
    #include <iostream.h>
    #include <string.h>
    #include <conio.h>
    
    char keyCode[26] = "qwertyuiopasdfghjklzxcvbnm";
    char input[255] = "";
    char ch;
    int i , j;
    
    void main(){
    	clrscr();
    	for ( i = 0 ; i <= 255; i++ ){
    		ch = getch();
    		if ( ch == 13 )
    			break;
    		cout << keyCode[ch - 'a' ];
    		j = strlen ( input );
    		input[j+1] = input [j];
    		input[j] = ch;
    	}
    	getch();
    }

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Haaaa , LOL there is a big quote, which we used to say alot in our school dayz.

    u need brain to copy also
    His friend gave him the code, he want to give the same assignment but with differ in style of coding. M i correct ???

  3. #3
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Ok, One hint use macros for const values

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Quote Originally Posted by RockyMarrone View Post
    Haaaa , LOL there is a big quote, which we used to say alot in our school dayz.



    His friend gave him the code, he want to give the same assignment but with differ in style of coding. M i correct ???
    the thing is I'm not in school I'm 22 years old I'm in a university and If they thought us this language in a proper time I would be able to solve my problem ... is it that hard for you to just help me ?

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,438
    naughty naughty, if you are copying.. any port in a storm though eh

    Ok, One hint use macros for const values
    this means e.g instead of the 'magic number' 255, you could replace with #define MAXLOOPS 255 (or whatever is the most appropriate name),put this after your #include statements, then put MAXLOOPS in the for loop instead of 255, same can be done with '13'

  6. #6
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Quote Originally Posted by rogster001 View Post
    naughty naughty, if you are copying.. any port in a storm though eh



    this means e.g instead of the 'magic number' 255, you could replace with #define MAXLOOPS 255 (or whatever is the most appropriate name),put this after your #include statements, then put MAXLOOPS in the for loop instead of 255, same can be done with '13'
    thanks ...
    any more help people ?

  7. #7
    Registered User
    Join Date
    Mar 2009
    Posts
    399
    Why on earth should we help you pass class that you obviously don't deserve to pass? You don't even have enough knowledge to cheat your way through the class ...

    C Board - Announcements in Forum : General Programming Boards

  8. #8
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Quote Originally Posted by Memloop View Post
    Why on earth should we help you pass class that you obviously don't deserve to pass? You don't even have enough knowledge to cheat your way through the class ...

    C Board - Announcements in Forum : General Programming Boards
    If i had the knowledge I helped anyone with this kinda problem (where they have real excuse )
    but people are different ... and you can talk for yourself

  9. #9
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Quote Originally Posted by lucky4ever View Post
    If i had the knowledge I helped anyone with this kinda problem (where they have real excuse )
    but people are different ... and you can talk for yourself
    What we want that u shud try it first, at your end and if u find any problem, after tryin hard u should get in here than..

    By this way your learning will be faster.

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Problem is, if you can't even re-arrange an easy program like this, what in the name of heaven are you going to do when you're asked about something in it, by the teacher? Or when you have to take your tests!

    You've got to do better than you're showing here, or you should immediately drop the class, and get prepared for it better, next semester.

    Reminds me of a funny story about a guy who moved to the West Coast, and decided to take up surfing. Got a board, a wetsuit,, all the gear. Went out on a stormy day (big waves), and finally got up on the board - just before another big wave slammed him down. He couldn't get air, he's being beat all around like he's in a washing machine.

    Finally, he gets to the surface, and paddles to shore. His board's skeg (rudder), has cut his foot up bad, and he needs a dozen stitches and a cast at the emergency room. His head is likewise needing some attention with stitches.

    But he tells his buddy, "Gotta go back and do it right!". so back to the beach they go. He wraps and tapes a garbage bag over his casted foot, and brings out his board and such, right to the water's edge.

    Then he screams in rage, and throws the surfboard as far out into the water as he could, and drove off for a beer, with his friend.

    "Because every man has to know his limits."

  11. #11
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Well Said Adak

  12. #12
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Quote Originally Posted by RockyMarrone View Post
    What we want that u shud try it first, at your end and if u find any problem, after tryin hard u should get in here than..

    By this way your learning will be faster.
    Okay I'm gonna try as much as i can and I'll paste the results here soon

  13. #13
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Now you're talking! Hope you mean it.

  14. #14
    Registered User
    Join Date
    Jan 2010
    Posts
    6
    Quote Originally Posted by Adak View Post
    Now you're talking! Hope you mean it.
    Oh believe me I mean it ... it's just i don't have the time and money to take this course next semester ... I know you don't believe a word I'm sayin but that's okay because you don't live in my country and are not in my shoes to understand what i'm saying ...

    ********

    I re wrote it and I'm trying to put it like below ... but it doesn't work when i run it it types the alphabet correctly but i want it to type the wrong alphabet like the first source!

    Code:
    #include <iostream.h>
    #include <conio.h>
    #include <string.h>
    int i , x , s;
    char ch;
    struct sentence{
         char name[50];
    	 char keyCode[] = "abcdefghijklmnopqrstuvwxyz";
         char input[255] = "";
    	 };
    struct sentence read(){
        struct sentence s;
    	return(s);
    	};
    void print(struct sentence s){
        	for ( i = 0 ; i <= 255; i++ ){
    		ch = getch();
    		if ( ch == 13 )
    			break;
    		cout << keyCode[ch - 'a' ];
    		x = strlen ( input );
    		input[x+1] = input [x];
    		input[x] = ch; }
    		};
    	
    
    
    
    
    void main(){
        cin >>s;
        cout <<"my name";
    	clrscr();
    	};

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help - rewriting style of string library in C
    By ~C_Student~ in forum C Programming
    Replies: 24
    Last Post: 11-19-2009, 09:34 PM
  2. Replies: 0
    Last Post: 07-23-2009, 04:20 AM
  3. rewriting my server
    By xixpsychoxix in forum Networking/Device Communication
    Replies: 5
    Last Post: 07-01-2008, 08:50 PM
  4. Rewriting a for loop as a while/do-while loop
    By Ashfury in forum C++ Programming
    Replies: 7
    Last Post: 04-27-2007, 03:20 PM
  5. Rewriting an opened file.
    By Daghdha in forum C Programming
    Replies: 5
    Last Post: 06-13-2002, 02:55 AM

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