Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

White Crow

can someone explain this exercise?

This topic is 5426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am stuck on an exercise because english is not my best language, this is the exercise: Write a program that replaces tabs in its input with the proper number of blanks to space to the next tab stop. Do they mean that every time TAB is pressed, let''s say the number 3 is has to be outputted to the screen or that if you press TAB multiple times a variable keeps incrementing until you press another key and then the variable is outputted to the screen? Thanks in advance Whitecrow

Share this post


Link to post
Share on other sites
Advertisement
Naa, it just means you should replace tab characters (was it ascii sign 9?) with, say, 4 spaces (ascii sign 32) ... this is done in some areas because some output windows doesn''t know how to handle tabs... or such

Albert

Share this post


Link to post
Share on other sites
As thec said it might be replace each tab with 4 spaces but more likely I think it is the following as the question is to the next tab stop:

In a word document or something similar you have tab stops at positions such as:
0 4 8 12

You could type ''cheers'' then hit . You would not expect the program to produce 4 spaces but in this case 2 to take you to the next tab stop at position 8.

Example of typing in cheersmate (. denoutes space)
0 4 8 12
Cheers..mate

Does that make sense?

Share this post


Link to post
Share on other sites
I had a function that reads input from the keyboard into an array but I have a problem with it now, but first the code



void getinput (char r[], int limit) // read input into r.

{
int i , c, , n = 4;

for(i=0; i<limit && (c=getchar()) != EOF && c!=''\n''; ++i)
{
if (c!= ''\t'')
{
r[i] = c;
--n;

if (n=0)
n=4;
}

else
{
// here r[i] must get the value of n but

// but how do I so? I mean putting the

// value of a variable into a string?




}
}

if(c==''\n'')
{
r[i] =c;
++i;
}

r[i] =''\0'';


}



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!