Add space to a string - c

I am trying to add a space to each space until column = 0. I am not sure how to do this.
The problem is the following. If you look at a newspaper you will see that the writing is justified to fit into the columns. Write a program
that reads in the width of the columns in a newspaper and then a line of text. Justify the line of text to fit into
a column of that width. When your program is running, the screen should look something like this:
Enter the width of the column: 40
Enter a line of text: Good morning how are you?
12345678901234567890123456789012345678901234567890...
Good morning how are you?
The justification is done by counting the number of gaps in the text. In the above example, there are 4 gaps. Then each gap must have spaces added to it. The number of extra spaces must be shared out as evenly as possible. In the above example, the first three gaps have 5 spaces each and the last gap has 4 spaces.
Notes:
If the text is longer than the column then you must report an error – don't try and break it into two lines!
Assume that the text will have more than one word in it.
Note the header line consisting of 123456789012345678.... this is useful to check your result.
You can make this header line as long as you like – 70 spaces would be a useful length.
Thanks
#include <stdio.h>
int clear_input_buffer(void);
int column;
int c;
int g;
int e;
int space;
int length;
char line[40];
int main(){
g = 0;
printf("enter width of column\n");
scanf("%d", &column);
printf("enter line of text\n");
clear_input_buffer();
gets(line);
c = 0;
while(c <= column){
if(g <= 9)
{
printf("%d", g);
g = g + 1;
c = c + 1;
}
else
{
g = 0;
printf("%d", g);
g = g + 1;
c = c + 1;
}
}
printf("\n%s", line);
space = 0;
length = 0;
for( e = 0; line[e] != '\0'; e++ )
{
length = length + 1;
if( line[e] == ' ' )
space = space + 1;
}
column = column - length;
for( e = 0; line[e] != '\0'; e++ )
{
if((line[e] == ' ') && (column > 0))
{
add space to here
column = column - 1;
}
}
printf("%d\n", space);
printf("%d", length);
printf("%s", line);
}
int clear_input_buffer(void) {
int ch;
while (((ch = getchar()) != EOF) && (ch != '\n')) /* void */;
return ch;
}

This is what i made. It's far from ideal, but you get the point.
You just need to put in conditions, like when the string entered is larger or equal than 40 chars, to skip the procedure.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
int i = 0; // first just initialiaze stuff
char ch[40]; // memset the arrays, get the string
memset(ch, '\0', 40);
gets(ch);
int diff = 40 - strlen(ch);
int spaces = 0;
while(i<strlen(ch))
{
if(*(ch + i++) == ' ') // count the number of words/spaces between words
spaces++;
}
char finalt[40];
memset(finalt, '\0', 40);
i = 0;
diff /= spaces; // diff is the number of spaces to be added between every word
i = 0;
int j = 0; // j is for the finalt array
int k = 0; // k counts through the while, to put in spaces
printf("%d\n", diff);
while(i<40) // just squeeze in the spaces
{
if(ch[i] == ' ') {while(k<diff){ finalt[j++] = ' '; k++;} k = 0;}
else {finalt[j] = ch[i]; j++;}
i++;
}
printf("%s\n", finalt); // print the result
return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define WIDTH 70
#define _(x) #x
#define str(x) _(x)
void ruler_print(int n){
char ruler[] = "1234567890";
while(n>9){
printf(ruler);
n -= 10;
}
ruler[n] = '\0';
printf("%s\n", ruler);
}
int count_word(const char *text, size_t *count_char){
int i;
char *wk, *p;
p=wk=strdup(text);
*count_char=0;
for(i=0;p=strtok(p, " ");++i,p=NULL){
*count_char+=strlen(p);
}
free(wk);
return i;
}
int main(void){
int column, len, word_count;
int i, spaces, between, remain;
size_t count_char;
char text[WIDTH + 1];
char *p = text;
printf("Enter the width of the column: ");scanf("%d%*c", &column);
printf("Enter a line of text: ");scanf("%" str(WIDTH) "[^\n]", text);
len=strlen(text);
if(len > column || len > WIDTH){
fprintf(stderr, "too long text!\n");
return -1;
}
ruler_print(WIDTH);
word_count = count_word(text, &count_char);
spaces = column - count_char;
between = spaces / (word_count -1);
remain = spaces - (word_count -1)*between;
strtok(text, " ");
for(i=0;i<word_count-1;++i){
printf("%s%*s", p, between + (remain ? 1 : 0), " ");
if(remain) --remain;
p=strtok(NULL, " ");
}
printf("%s\n", p);
return 0;
}

Related

why can't my program recognize similar words in a string?

I want to write a program that will take an input T. In the next T lines, each line will take a string as an input. The output would be how many ways the string can be reordered.
#include <stdio.h>
#include <stdlib.h>
int main() {
int T, i, l, count = 1, test = 0, word = 0, ans;
char line[200];
scanf("%d", &T);
for (i = 0; i < T; i++) {
scanf(" %[^\n]", line);
l = strlen(line);
for (int q = 0; q < l; q++) {
if (line[q] == ' ') {
word++;
}
}
ans = fact(word + 1);
word = 0;
for (int j = 0; j < l; j++) {
for (int k = j + 1; k < l; k++) {
if (line[k] == ' ' && line[k + 1] == line[j]) {
int m = j;
int n = k + 1;
for (;;) {
if (line[m] != line[n]) {
break;
} else
if (line[m] == ' ' && line[n] == ' ') {
test = 1;
break;
} else {
m++;
n++;
}
}
if (test == 1) {
count++;
ans = ans / fact(count);
count = 0;
test = 0;
}
}
}
}
printf("%d\n", ans);
}
}
int fact(int n) {
if (n == 1) {
return 1;
} else {
return n * fact(n - 1);
}
}
Now, in my program,
my output is like this:
2
no way no good
12
yes no yes yes no
120
if T = 2 and the 1st string is no way no good, it gives the right output that is 12 (4!/2!). That means, it has identified that there are two similar words.
But in the 2nd input, the string is yes no yes yes no. that means 3 yes and 2 nos. So the and should be 5!/(3!2!) = 10. But why is the answer 120? and why can't it recognize the similar words?
The main problem in your duplicate detector is you test the end of word with if (line[m] == ' ' && line[n] == ' ') but this test fails to identify a duplicate that occurs with the last word because line[n] is '\0', not ' '.
Note these further problems:
you do not handle words that occur more than twice correctly: you should perform ans = ans / fact(count); only after the outer loop finishes. For example, if a word is present 3 times, it will be detected as 3 pairs of duplicates, effectively causing ans to be divided by 23 = 8, instead of 3! = 6.
you should protect against buffer overflow and detect invalid input with:
if (scanf(" %199[^\n]", line) != 1)
break;
the range of type int for ans is too small for a moderately large number of words: 13! is 6227020800, larger than INT_MAX on most systems.
The code is difficult to follow. You should consider parsing the line into an array of words and using a more conventional way of counting duplicates.
Here is a modified version using this approach:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int cmpstr(const void *p1, const void *p2) {
char * const *pp1 = p1;
char * const *pp2 = p2;
return strcmp(*pp1, *pp2);
}
unsigned long long factorial(int n) {
unsigned long long res = 1;
while (n > 1)
res *= n--;
return res;
}
int main() {
int T, i, n, begin, count;
unsigned long long ans;
char line[200];
char *words[100];
if (!fgets(line, sizeof line, stdin) || sscanf(line, "%d", &T) != 1)
return 1;
while (T --> 0) {
if (!fgets(line, sizeof line, stdin))
break;
n = 0;
begin = 1;
for (char *p = line; *p; p++) {
if (isspace((unsigned char)*p)) {
*p = '\0';
begin = 1;
} else {
if (begin) {
words[n++] = p;
begin = 0;
}
}
}
qsort(words, n, sizeof(*words), cmpstr);
ans = factorial(n);
for (i = 0; i < n; i += count) {
for (count = 1; i + count < n && !strcmp(words[i], words[i + count]); count++)
continue;
ans /= factorial(count);
}
printf("%llu\n", ans);
}
return 0;
}

Spaces shouldn't be counted to string length

This code gets user input then 256 % length of string is used. If the result is 3 and the input is abc the output is bcd. This works fine. However if the input is for example "hey whatsup" the length is 11 and it should be 10 because the space shouldn't be included for the length.
How can I programm this code so it dosen't count space to the length?
Is it even possible to implement it while using fgets?
Thank you in advance.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
char array[20];
int length = 0;
int i;
int key = 256;
printf("input: ");
fgets(array, 20, stdin);
length = strlen(array) - 1;
key = key % length;
if (key > 0) {
for (i = 0; i < length; i++) {
if (array[i] == ' ') {
printf("%c", array[i]);
continue;
}
array[i] = array[i] + key;
printf("%c", array[i]);
}
}
return 0;
}
1) If you don't want to include the spaces in the calculation of the key, you have to make your own function to calculate the number of spaces.
2) The code length = strlen(array) - 1; seems to "take care" of a '\n' in the end of the string. However, you can't be sure that there is a '\n'. You need to check for that first.
3) Doing key % 0 will be "bad" so check for that as well
The code could look something like:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cnt_spaces(char* arr)
{
int res = 0;
while(*arr)
{
if (*arr == ' ')
{
++res;
}
++arr;
}
return res;
}
int main() {
char array[20];
int length = 0;
int i;
int key = 256;
printf("input: ");
fgets(array, 20, stdin);
length = strlen(array);
if (strlen(array) == 0) return 0; // or add error handling
// Remove \n if present
if (array[length-1] == '\n')
{
array[length-1] = '\0';
--length;
}
printf("len = %d\n", length);
int spaces = cnt_spaces(array);
printf("spaces = %d\n", spaces);
if (length == spaces) return 0; // or add error handling
key = key % (length - spaces);
printf("key = %d\n", key);
if (key > 0) {
for (i = 0; i < length; i++) {
if (array[i] != ' ') {
array[i] = array[i] + key;
}
printf("%c", array[i]);
}
}
return 0;
}
Example:
input: a b c
len = 5
spaces = 2
key = 1
b c d

Count and get integers from a string using C

I am self teaching C programming.
I am trying to count number of int present in given string which are separated by space.
exp:
input str = "1 2 11 84384 0 212"
output should be: 1, 2, 11, 84384, 0, 212
total int = 6
When I try. It gives me all the digits as output which make sense since I am not using a right approach here.
I know in python I can use str.split (" ") function which can do my job very quickly.
But I want to try something similar in C. Trying to create my own split method.
#include <stdio.h>
#include <string.h>
void count_get_ints(const char *data) {
int buf[10000];
int cnt = 0, j=0;
for (int i=0; i<strlen(data); i++) {
if (isspace(data[i] == false)
buf[j] = data[i]-'0';
j++;
}
printf("%d", j);
}
// when I check the buffer it includes all the digits of the numbers.
// i.e for my example.
// buf = {1,2,1,1,8,4,3,8,4,0,2,1,2}
// I want buf to be following
// buf = {1,2,11,84384,0,212}
I know this is not a right approach to solve this problem. One way to keep track of prev and dynamically create a memory using number of non space digits encountered.
But I am not sure if that approach helps.
You want to build your number incrementally until you hit a space, then put that into the array. You can do this by multiplying by 10 then adding the next digit each time.
void count_get_ints(const char *data) {
int buf[10000];
int j = 0;
int current_number = 0;
// Move this outside the loop to eliminate recalculating the length each time
int total_length = strlen(data);
for (int i=0; i <= total_length; i++) {
// Go up to 1 character past the length so you
// capture the last number as well
if (i == total_length || isspace(data[i])) {
// Save the number, and reset it
buf[j++] = current_number;
current_number = 0;
}
else {
current_number *= 10;
current_number += data[i] - '0';
}
}
}
I think strtok will provide a cleaner solution, unless you really want to iterate over every char in the string. It has been a while since I did C, so please excuse any errors in the code below, hopefully it will give you the right idea.
#include <stdio.h>
#include <stdlib.h>
int main() {
char str[19] = "1 2 11 84384 0 212";
const char s[2] = " ";
char *token;
int total;
total = 0;
token = strtok(str, s);
while (token != NULL) {
printf("%s\n", token);
total += atoi(token);
token = strtok(NULL, s);
}
printf("%d\n", total);
return 0;
}
You can check the ascii value of each character by doing c-'0'. If it's between [0,9], then it's an integer. By having a state variable, when you're inside an integer by checking if a given character is a number of space, you can keep track of the count by ignoring white space. Plus you don't need a buffer, what happens if data is larger than 10,000, and you write pass the end of the buffer?, undefined behavior will happen. This solution doesn't require a buffer.
Edit, the solution now prints the integers that are in the string
void count_get_ints(const char *data) {
int count = 0;
int state = 0;
int start = 0;
int end = 0;
for(int i = 0; i<strlen(data); i++){
int ascii = data[i]-'0';
if(ascii >= 0 && ascii <= 9){
if(state == 0){
start = i;
}
state = 1;
}else{
//Detected a whitespace
if(state == 1){
count++;
state = 0;
end = i;
//Print the integer from the start to end spot in data
for(int j = start; j<end; j++){
printf("%c",data[j]);
}
printf(" ");
}
}
}
//Check end
if(state == 1){
count++;
for(int j = start; j<strlen(data); j++){
printf("%c",data[j]);
}
printf(" ");
}
printf("Number of integers %d\n",count);
}
I believe the standard way of doing this would be using sscanf using the %n format specifier to keep track of how much of the string is read.
You can start with a large array to read into -
int array[100];
Then you can keep reading integers from the string till you can't read anymore or you are done reading 100.
int total = 0;
int cont = 0;
int ret = 1;
while(ret == 1 && total < 100) {
ret = sscanf(input, "%d%n", &array[total++], &cont);
input += cont;
}
total--;
printf("Total read = %d\n", total);
and array contains all the numbers read.
Here is the DEMO
Example using strtol
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
int count_get_ints(int output[], int output_size, const char *input) {
const char *p = input;
int cnt;
for(cnt = 0; cnt < output_size && *p; ++cnt){
char *endp;
long n;
errno = 0;
n = strtol(p, &endp, 10);
if(errno == 0 && (isspace((unsigned char)*endp) || !*endp) && INT_MIN <= n && n <= INT_MAX){
output[cnt] = n;
while(isspace((unsigned char)*endp))
++endp;//skip spaces
p = endp;//next parse point
} else {
fprintf(stderr, "invalid input '%s' in %s\n", p, __func__);
break;
}
}
return cnt;
}
int main(void) {
const char *input = "1 2 11 84384 0 212";
int data[10000];
int n = sizeof(data)/sizeof(*data);//number of elements of data
n = count_get_ints(data, n, input);
for(int i = 0; i < n; ++i){
if(i)
printf(", ");
printf("%d", data[i]);
}
puts("");
}
Assuming you don't have any non-numbers in your string, you can just count the number of spaces + 1 to find the number of integers in the string like so in this pseudo code:
for(i = 0; i < length of string; i++) {
if (string x[i] == " ") {
Add y to the list of strings
string y = "";
counter++;
}
string y += string x[i]
}
numberOfIntegers = counter + 1;
Also, this reads the data between the white spaces. Keep in mind this is pseudo code, so the syntax is different.

word length statistic C language

Can anyone help me to make that project.
Write a program that calculates statistics on word length for a sentence. The sentence isterminated by a ’.’ For each found length of a word the number of words of that length
is printed. Only those lengths that are found in the input are printed. Only letters from
a-z or A-Z are allowed to form words. Words are separated by a space. No punctuation
characters other than ’.’ are allowed. If any other input character is recognized or the
input is longer than 80 characters the program displays ”NOT VALID” (see Hints). Note,
that in the case that no word is present in the input, nothing is printed.
% u6_stats
Enter a sentence: Bolt was expected to use the super bark.
Length 2: 1
Length 3: 3
Length 4: 2
Length 5: 1
Length 8: 1
% u6_stats
Enter a sentence: Something wasn’t right.
NOT VALID
#include <stdio.h>
#include <conio.h>
void main() {
char s[100];
int numOfWords, lengthOfWord = 0;
int i = 0, j = 0;
printf("Enter the text : ");
fgets(s, sizeof(s), stdin);
numOfWords = 1;
while(s[i]!='\0') {
if(s[i] == ' ')
numOfWords++;
i++;
}
//printf("%d", numOfWords);
i = 0;
int help[numOfWords];
int l;
for(l = 0; l < numOfWords ; l++)
help[l] = 0;
while(s[i]!='\0') {
if(s[i] != ' ' && s[i] !='\n' && s[i]!='.' ) {
lengthOfWord++;
i++;
}else{
help[j] = lengthOfWord;
j++;
lengthOfWord = 0;
i++;
}
}
int repeat[80];
for(l = 0; l < 80 ; l++)
repeat[l] = 1;
int num = 1;
i=0,l=0;
for(i = 0;i<numOfWords;i++) {
for(l=i+1;l<numOfWords;l++)
if(help[i]==help[l]) {
repeat[l]='\0';
num++;
repeat[i] = num;
}
num = 1;
}
l=0;
for (l=0; l<numOfWords; l++)
if (repeat[l]!='\0' && help[--l]!=help[++l])
printf("Length %d: %d\n", help[l],repeat[l]);
}
So, the problem is that if i inpute a text like"abc abcd abc abc"
the result will be like "length 3: 3 length 4: 1 length 3: 2".
So when the program already compared 1st (here 3) element with otheres, this element will not be comparing again, but i have the 3d element with same length, and it that case, the program compare it with remained elements and print 2. How can i rework my code, if i dont wont to compare already compared elements.
Second problem is that i need to get results from lowest length till highst.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void invalid(void){
puts("NOT VALID");
exit(EXIT_FAILURE);
}
int main(void){
int length[80]={0};
int i, ch, word_len=0;
printf("Enter a sentence: ");
while(1){
ch=getchar();
if(isalpha(ch)){
++word_len;
} else if(ch == ' ' || ch == '.'){
if(word_len>80)
invalid();
if(word_len)
length[word_len-1]++;//-1: to 0 origin
if(ch == '.')
break;
word_len = 0;
} else {
invalid();
}
}
for(i=0;i<sizeof(length)/sizeof(*length);++i){
if(length[i])
printf("Length %d: %d\n", i+1, length[i]);
}
return 0;
}
A simple approach is with strtok (http://www.tutorialspoint.com/c_standard_library/c_function_strtok.htm).
#include <stdio.h>
int numwords (char *str);
int main() {
char word[] = "This is a test - does it pass?";
int c = numwords(word);
printf("Words = %d\n", c);
return 0;
}
int numwords(char *str)
{
int n = 0;
for(str=strtok(str, " -.!,;"); str; str=strtok(NULL, " -.!,;"))
n++;
return n;
}

Replace spaces with tab character

I just finished the first chapter of The C Programming Language and there are a few exercises before moving on. I already completed the one to replace the tab character with spaces which was fairly easy, but I am stuck on the one to replace space characters with the proper amount of tabs and spaces to achieve the same spacing.
My implementation "sometimes" works, so essentially it doesn't work. Here is the function:
#define TABLEN 5
// entab: replace consecutive spaces of length TABLEN with the tab character
void entab(char string[])
{
int i, consec;
int to, from, tabloc;
consec = 0;
for (i = 0; string[i] != '\0'; ++i) {
// count consecutive spaces in a string
if (string[i] == ' ') ++consec;
else consec = 0;
if (consec >= TABLEN) {
// set location to insert tab character
tabloc = (i - TABLEN) + 1;
for (to = tabloc, from = i;
string[from] != '\0'; ++from, ++to)
{
// replace space characters
string[to] = string[from];
}
string[tabloc] = '\t';
string[to] = '\0';
i = tabloc;
consec = 0;
}
}
}
This function is extremely inconsistent in working successfully to the point where there isn't even a pattern of when it does and doesn't work. By "doesn't work", I mean one of two situations. 1.) the spaces are deleted and no tab character is inserted, or 2.) the spaces are deleted, a tab character is inserted, but somehow an extra space is added in. These issues have led me to realize that the problem exists in the loop that replaces the spaces, but I'm so new to C that I have no idea what is wrong. Can someone point me in the right direction here?
Here's how tabs work:
If you typed
Tab
v v v v
------------------------
| a
|a a
|aa a
|aaa a
|aaaa a
Notice how if there was 5, 4, 3, 2, or 1 spaces, they all could be equally represented as a tab. This is why 5 spaces doesn't equal a tab (even when the tab size is set to 5). Consider this case as well:
v v v v
------------------------
|aaaa a
| 12345
But when you replace those 5 spaces with a tab, you get:
v v v v
------------------------
|aaaa a
| 12345
Here's an working example:
#include <stdio.h>
#include <string.h>
void Print_As_String(char * buffer, unsigned int size);
void Print_As_Hex(char * buffer, unsigned int size);
void Convert_Tab_To_Space(char * buffer, unsigned int size, unsigned int tab_size);
int main(unsigned int argc, char * argv[]){
unsigned int i = 0;
unsigned int arg_length = 0;
if (argc <= 1){
printf("Usage: \"Text with spaces\", \"More text with spaces\", etc\n");
return -1;
}
for (i = 1; i < argc; i++){
arg_length = strlen(argv[i]);
Print_As_String (argv[i], arg_length);
Print_As_Hex (argv[i], arg_length);
Convert_Tab_To_Space(argv[i], arg_length, 8);
Print_As_String (argv[i], arg_length);
Print_As_Hex (argv[i], arg_length);
}
return 0;
}
void Print_As_String(char * buffer, unsigned int size){
printf("%.*s\n", size, buffer);
}
void Print_As_Hex(char * buffer, unsigned int size){
unsigned int i = 0;
const char hex_table[16] = "0123456789ABCDEF";
for (i = 0; i < size; i++){
unsigned char high_byte = 0;
unsigned char low_byte = 0;
high_byte = (buffer[i] & 0xF0) >> 4;
low_byte = (buffer[i] & 0x0F) >> 0;
putc(hex_table[high_byte], stdout);
putc(hex_table[low_byte], stdout);
putc(' ', stdout);
}
putc('\n', stdout);
}
void Shift_Characters_Left(char * buffer,
unsigned int position_start,
unsigned int position_end,
unsigned int size);
void Convert_Tab_To_Space(char * buffer, unsigned int size, unsigned int tab_size){
unsigned int i = 0;
unsigned int x = 0; /* x is used
for getting the position in
the current line. This is
different from 'i' because
there may be many lines in
one string.
*/
for (i = 0; i < size; i++){
if (buffer[i] == '\t'){ /* the x coordinates
change in this fashion when a new
tab is found.
*/
x += tab_size - (x % tab_size);
} else if (buffer[i] == ' '){
unsigned int tab_remainder = 0; // how many spots are left for a tab
unsigned int space_i = 1; // space index
tab_remainder = (x % tab_size);
while ((i + space_i) < size){
/* if the space count makes up for the
missing spots in the tab remainder,
replaces the spaces with a tab
*/
if ((tab_remainder + space_i) == tab_size){
Shift_Characters_Left(buffer, // move the spot at the end of
i + space_i, // the spaces to the spot at
i + 1, // the start of the spaces
size);
buffer[i] = '\t';
}
if (buffer[i + space_i] != ' '){
i += space_i;
break;
}
space_i++;
}
} else if (buffer[i] == '\n'){
x = 0;
} else {
x++;
}
}
}
void Shift_Characters_Left(char * buffer,
unsigned int position_start,
unsigned int position_end,
unsigned int size){
memmove(buffer + position_end,
buffer + position_start,
size - position_end);
memset(&buffer[position_start], 0, (size - 1) - position_start);
}
But there is an unaddressable error I get when I test this problem. I think it's something i'm doing wrong with memset (probably an off-by-one error).
The following works fine. Check the differences in the indexes
#include <stdio.h>
#define TABLEN 5
// entab: replace consecutive spaces of length TABLEN with the tab character
void entab(char string[])
{
int i, consec;
int to, from, tabloc;
printf("%s\n",string);
consec = 0;
for (i = 0; string[i] != '\0'; ++i) {
// count consecutive spaces in a string
if (string[i] == ' ') ++consec;
else consec = 0;
if (consec >= TABLEN) {
// set location to insert tab character
tabloc = (i - TABLEN) + 1;
for (to = tabloc+1, from = i+1;
string[from] != '\0'; ++from, ++to)
{
// replace space characters
string[to] = string[from];
}
string[tabloc] = '\t';
string[to] = '\0';
i = tabloc+1;
consec = 0;
}
}
printf("%s",string);
}
int main(void) {
// your code goes here
char a[] = "hello wor l d";
entab(a);
return 0;
}

Resources