how can i use ascii in my c++ program?-VBForums
Results 1 to 15 of 15

Thread: how can i use ascii in my c++ program?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746

    how can i use ascii in my c++ program?

    i want to make a program that creates directories using the ascii number 255 on the desktop. to do this i need to know how to do the following. i need to do this using dos because windows doesnt understand the ascii number 255.

    use the ascii number 255 in a md command.

    change the directory the dos prompt is pointing too.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Under windows, use 160 for the same effect
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    ye but how can i make do it using a c++ program. that way it would be automated.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    i dont understand how thats different from just assignning a number to it?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    and no it didnt work i got a error.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    when i try this i get a error something about assertion. its supposed to make a directory using the ascii character number 255. also how can i change the directory that dos prompt is pointing to?

    #include<iostream.h>
    #include<conio.h>
    #include<windows.h>

    int main()

    {

    system("md haha" + (char)255); // The c_str() returns a const char*


    return 0;


    }

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Cstrings won't concentrate with + operator. You have to use strcat to concentrate Cstrings, or you can use a string class.
    to get easy away, you can use the following trick with escape character:
    system("md haha\255");
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    alright, kedaman, that was what I was searching for, and that's why I used my weird solution
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    ye but i need it to be the ascii character number 255 ur exampe makes a directory called "haha-"

    the ascii character 255 looks like a underscore in windows.

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    as parksie said, dos 255 == windows 160
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    ye but isnt windows not supposed to be able to read that character so when u try to delete or open the folder it says it cant be found? how come when i do this:system("md haha99\160"); is creates a directory, but i can still open it.

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    what exactly does character 255 do? Isn't that the invisible trick character from dos? You were able to open those folders, but it was hard to identify thm.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    character 255 isnt understood by windows. if u go to dos prompt and make a directory using that character windows wont be able to identify it, open it, delete it, move it, etc.

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It can, it's just interpreted as 160.

    For example, create a folder with 255, then access it from windows using 160 - you get the same folder.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  15. #15
    amac
    Guest
    This sounds kinda like a bug I found in IE...

    I connected to my FTP (using IE) and tried to download something, and I got an error saying the file could not be found...

    So I logged in to investigate and I found that there was a space at the beginning of the filename. Once I removed it, I could download it fine.

    I guess IE trims spaces from the beginning of filenames. It is a UNIX server so its easy to put spaces at the beginning or end of filenames.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.