The default spaces of a '/t' on my system is 8 spaces. Is there anyway i can set the number of spaces to a different length?
The default spaces of a '/t' on my system is 8 spaces. Is there anyway i can set the number of spaces to a different length?
i need to write a program that replaces spaces with a tab. the string with the spaces entered must look the same after the program replaces it wz tabs. on my system win2k, '/t' tab which by default is displayed by 8 spaces . question is how do i set the length of the tab to any length i want in the code. thanx
Last edited by nilrac; 11-13-2002 at 04:04 AM.
What program do you use to display the information?Originally posted by nilrac
i need to write a program that replaces spaces with a tab. the string with the spaces entered must look the same after the program replaces it wz tabs. on my system win2k, '/t' tab which by default is displayed by 8 spaces . question is how do i set the length of the tab to any length i want in the code. thanx
In notepad for example you can't change the length of the tab.
i run the program in Dos command prompt. ask the user for an input and display the input string again but replace blankspaces wz a tab of 8 spaces or less depending on the number of spaces the user input. maybe i shld put it this way. say i want to write a simple text editor in C, that has a function which allows the user to set the number of spaces in a TAB. this was given as an excerise in a book. i been thinking for an soltion for days ...pls help. thanx
Last edited by nilrac; 11-13-2002 at 05:49 AM.
i'm using the command line borland compiler that they give out for free. i'm really sorry for repeating myself, not so good at phrasing my question. anywayz i got this problem frm a book 'C by Discovery' by Froster and Froster. the reason to replace blankspaces wz a tab is too reduce the byte size of the file. in the sample output in the bk . they have Tabs in different length. like this:
brown_ _ _ _ _ _cow
brown[ T a b ]cow
brown_ _ _cow
brown[TAB]cow
where _ represent a blankspace.
and the [ TAB ] is used to illustrate that a TAB is present.
the first line is entered by the user then the program will display line 2 with the spaces replace.
i know that '/t' in a printf statement will print out a TAB with 8 spaces in between and is the only way i know how to add a tab in the code. so i am wracking my brains as to how i can duplicate the output. if it is even possible?
Last edited by nilrac; 11-13-2002 at 05:50 AM.
A tab is a single byte. It's up to the editor you're viewing the file in to determine how many "spaces" it is displayed as. It never actually is a space though.Originally posted by nilrac
i know that '/t' in a printf statement will print out a TAB with 8 spaces in between and is the only way i know how to add a tab in the code. so i am wracking my brains as to how i can duplicate the output. if it is even possible?
You can convert multiple spaces to a tab simply but looping through the string, and when you spot 2 spaces in a row, output a tab and then throw away anymore spaces until you get to the next non-space character. If that's what you want to do, that is.
Does that help?
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
yes it did help. well, actually i misinterpreted the question. my part to blame . It shld be done ur way ...thanxOriginally posted by Hammer
A tab is a single byte. It's up to the editor you're viewing the file in to determine how many "spaces" it is displayed as. It never actually is a space though.
You can convert multiple spaces to a tab simply but looping through the string, and when you spot 2 spaces in a row, output a tab and then throw away anymore spaces until you get to the next non-space character. If that's what you want to do, that is.
Does that help?
since \t has 8 spaces in windows.
what if i want it to have 9 or 10, or even more spaces. can it be done? say if i only run my program in the dos command prompt and not redirected to other text editor or applications.
>>since \t has 8 spaces in windows.
No. It may look the equivalent of 8 spaces, but thats only because your application settings say so, it has nothing to do with Windows.
For example, I use Ultra Edit as my text editor. in the setting panel I can customise how many spaces a tab gives.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]