Question

(written in c )How to split a string into lines without breaking the word that exceeds...

(written in c )How to split a string into lines without breaking the word that exceeds the limit.
for example , each line is limited at 5 strings

input : one 1 two three
output: one 1
two
three

thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <string.h>
  
int main()
{
char st[] = "each line is limited at 5 strings";
  

char *token = strtok(st, " ");
  
while (token != NULL)
{
printf("%s\n", token);
token = strtok(NULL, " ");
}
  
return 0;
}

Add a comment
Know the answer?
Add Answer to:
(written in c )How to split a string into lines without breaking the word that exceeds...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone help me with this, and it has to be written in the C programming...

    Can someone help me with this, and it has to be written in the C programming language: Write a program that reads a string from the keyboard. If the length of the string is an even number, your program should split the string into two strings of equal length. If the length of the string is odd, your program should split the string into two strings where the first part has one more character than the second part. Your program...

  • The program needs to be written in C. Write a function void camelCase(char* word) where word...

    The program needs to be written in C. Write a function void camelCase(char* word) where word consists of more than two words separated by underscore such as “random_word” or "hello_world_my_name_is_sam". camelCase() should remove underscores from the sentence and rewrite in lower camel case” (https:// en.wikipedia.org/wiki/Camel_case). Watch out for the end of the string, which is denoted by ‘\0’. You have to ensure that legal strings are given to the camelCase() function. The program should only run when the input is...

  • Goal:   Unscramble permuted words by generating all permutations of Jumble string and searching for a word...

    Goal:   Unscramble permuted words by generating all permutations of Jumble string and searching for a word in Unix dictionary. Unix Dictionary: dict.txt Details: Write a method called get_permutations that inputs a string like "dog". Your method should return an array of all permutations of the Jumble string. . For example: s = "dog" perms = get_permutations(a) print(perms) Output: ['dog', 'dgo', 'odg', 'ogd', 'gdo', 'god'] Rewrite the script for obtaining permutations and the end of the Comments, Hints, and Observersions section...

  • String Processing Labs Directions: Write a main program to test the three functions described below, Input...

    String Processing Labs Directions: Write a main program to test the three functions described below, Input is from a file, and output is to a file. 1. The function Another parameter is a char variable with a letter value. The function outputs the number of times the char value appears in the string. processes a string containing letters of the alphabet, which is a parameter 2. This Boolean function has two string parameters. It returns true when the first str...

  • Swap Cases - Write a python program to swap cases. LowerCase letters to Upper case and...

    Swap Cases - Write a python program to swap cases. LowerCase letters to Upper case and vice versa (10 points) Input : Www.PyDev.com Output: wWW.pYdEV.COM Input: Pythonist 2 Output: pYTHONIST 2 b) Manipulate Strings - Insert a sequence of characters into the specified position in the given String(10 points) Input : First Line contains the string to be manipulated Second Line contains the string to be inserted and the position Number Output : The modified string Sample Input & Output:-...

  • 6.6 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains...

    6.6 Warm up: Parsing strings (Python 3) (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two...

  • C++Language: The question is not allowed to use STL. Also, plz use noskipws and push_back for the question.The input is...

    C++Language: The question is not allowed to use STL. Also, plz use noskipws and push_back for the question.The input is more than one, so the code should be able to run more than once Strings are vectors words on that line and the line itself. What's a word? It is a series of alphabetic characters, separated by whitespace other non-alphabetic characters. Write a program that reads from cin and tor each line, outputs number Pretty easy huh, well, you aren't...

  • Write a function palcheck (char word II) which takes a C-style string word (or a C++...

    Write a function palcheck (char word II) which takes a C-style string word (or a C++ string word if you wish) and returns or false depending on whether or not the string is a palindrome. (A palindrome is a string which reads the same backwards and forwards. Some classic example of palindromes are radar, racecar, toot, deed, bib, civic, redder and madam.) Use your function from part (a) in a complete C++ program which, for each small letter 'a' through...

  • You are given a set of ABC cubes for kids (like the one shown below) and a word. On each side of ...

    You are given a set of ABC cubes for kids (like the one shown below) and a word. On each side of each cube a letter is written 7 FI 0 You need to find out, whether it it possible to form a given word by the cubes For example, suppose that you have 5 cubes: B1: MXTUAS B2:OQATGE ВЗ: REwMNA B4: MBDFAC В5: IJKGDE (here for each cube the list of letters written on its sides is given) You...

  • In c programming, I need to write a program that reverses each of the lines in...

    In c programming, I need to write a program that reverses each of the lines in a file. The program accepts two command line arguments: The first one is the name of the input file The second is the name of the output file If the user didn't give two filenames, display an error message and exit. The program reads in each line of the input file and writes each line in reverse to the output file. Note, the lines...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT