MY DECRYTER IS COMPLETED! cept 4 spaces...

This is a discussion on MY DECRYTER IS COMPLETED! cept 4 spaces... within the C++ Programming forums, part of the General Programming Boards category; If you want to have some fun crypting messages to ur friends to decrypt, use it :P if you want ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    206

    MY DECRYTER IS COMPLETED! cept 4 spaces...

    If you want to have some fun crypting messages to ur friends to decrypt, use it :P if you want to crypt programs and actual files... gimme some time!! IF YOU KNOW HOW TO SKIP SPACES AND NEWLINES PLEASE PLEASE PLEASE TELL ME! THEN I WILL BE DONE!! please try it and tell me how it works(remember, no spaces or newlines)

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    206
    file...
    Attached Files Attached Files

  3. #3
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    I told you how to skip spaces and newlines, you dork

    Code:
    while( (c = getchar()) != EOF )
    {
       switch( c )
       {
          case ' ': case '\n':
             // Skip these
             break;
          default:
             // Do your normal ciphering
             break;
       }
    }
    That is another way to do it. Also, like I said before, you could use isspace() from ctype.h.
    Last edited by biosx; 03-26-2002 at 10:36 AM.

  4. #4
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    Awwww, I'm so proud.

    One thing, though.. You shouldn't define functions in header files. You put prototypes in header files and the function definitions in a .c file.

  5. #5
    Unregistered
    Guest
    that header file to me, isnt really a header file... kinda. those arent normal functions... kind. heh. Im using it as my own personal library for every c++ file i make. So itll be easier to make them. did you see my cpp file? lol its not even a page, thanks to my library.

  6. #6
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    That's not the point.

    This is how it should be:

    main.cpp
    Code:
    #include "abbrev.h"
    
    int main()
    {
        // foo
    }
    abbrev.h
    Code:
    #ifndef ABBREV_H
    #define ABBREV_H
    
    #define MAX 1024
    
    /* Function prototypes */
    int foobar(int a);
    char fooey(char *str);
    void fubar(double stuf_oreo);
    
    #endif
    abbrev.c
    Code:
    #include's
    
    int foobar(int a)
    {
       printf("%c", a);
       return 0;
    
    }
    
    char fooey(char *str)
    {
       printf("%s", str);
       return *str;
    }
    
    //etc. etc. etc.
    Then you compile both abbrev.c and main.c together.

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    206
    fdgsfdg
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    Mar 2002
    Posts
    13
    hehe, try:
    #include <io.h>
    #include <fcntl.h>
    #include <iostream.h>

    void main()
    {
    int i, j = 0;
    int key_length;
    int fh_in, fh_out;
    long buffer_length;
    long bytes_read = 0, file_length;
    char in_buf[65536], out_buf[65536];
    char infile[256], outfile[256];
    char key[64] = {0};

    cout << "SRC: ";
    cin.getline(infile, 256, '\n');
    cout << "DST: ";
    cin.getline(outfile, 256, '\n');
    cout << "PSW: ";
    cin.getline(key, 64, '\n');

    fh_in = open(infile, O_BINARY | O_RDONLY);
    fh_out = open(outfile, O_BINARY | O_WRONLY | O_CREAT);

    file_length = filelength(fh_in);

    for (i = 63; i > 0; i--) if (key[i] == 0) key_length = i;

    while (!eof(fh_in))
    {
    buffer_length = file_length - bytes_read;
    if (buffer_length > 65536) buffer_length = 65536;

    read(fh_in, in_buf, buffer_length);

    for (i = 0; i < buffer_length; i++)
    {
    out_buf[i] = in_buf[i] ^ key[j];
    j++;
    if (j == key_length) j = 0;
    }

    write(fh_out, out_buf, buffer_length);

    bytes_read += buffer_length;
    }

    close(fh_in);
    close(fh_out);
    }

    works on all files, very optimized
    4 mb in about 0.1 secs

  9. #9
    Rez
    Guest

    Smile reply 2 ur problem

    hi there!

    ur problem is quite simple. anyway, try to look up standard C's "ctype.h". functions like isspace() etc... like that exists there.

    sample:

    fread(&chr, sizeof(char), 1, filename);
    if(isspace(chr) || chr == '\n') {
    ...more code...
    ...more code...
    ...break out to skip...
    }

    that's all u can improve it.

    -Rez

  10. #10
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230

    Re: reply 2 ur problem

    Originally posted by Rez
    hi there!

    ur problem is quite simple. anyway, try to look up standard C's "ctype.h". functions like isspace() etc... like that exists there.
    -Rez
    Did you not see my first post No use in repeating.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-22-2008, 12:51 AM
  2. saving a CString to binary file with trailing spaces
    By nineofhearts in forum C++ Programming
    Replies: 12
    Last Post: 01-03-2006, 11:53 AM
  3. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 09:44 AM
  4. Handling spaces in command line arguments
    By starkhorn in forum C++ Programming
    Replies: 7
    Last Post: 11-16-2004, 02:42 PM
  5. Replies: 5
    Last Post: 06-30-2003, 01:52 PM

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