I'm learning programming, and C++. I've got a question, but I couldn't solve my problem so far. I need to use arrays and only basic stuff to solve this:
Create a program that reads a word from the user and then print (cout) this word on contrary. It's simple, I know, but I can't do it,. I've tried some stuff but I don't get how I will get the proper values to do this. All I know is that I can use variable.lenght().
I have done an exercise from "Thinking in C++" to print text from a file to the console one line at a time, with the user pressing enter to get the next line.
My original code is below, how could I change it for one word at a time?
I tried to alter my program to print one word at a time by changing "getline(in, word)" to "in >> word", but it prints each new word on a new line, the only input I have found to make the next word appear is Enter, I assume that's why.
Is there a way to make it print one word at a time when the user says, but on the same line?
I have previous threads asking how to make a list of words that were matched up be printed out into a .css or .txt
Is there anyway to make the words being printed out in CMD after debugging/compiling a script printed out in a .txt/.cpp file instead? CMD only has 300 lines. I need the outcome to be printed out elsewhere so more lines can be posted rather than 300.
1. Create a variable named index and nitialize it to zero(0) 2. Prompt for and input a string value from thekeyboard. Store the string inthe string variable newstring[80]. 3. While (newstring[index] does not equal ‘ ’).
i. Display the character at newstring[index] followed by a NL ii. Increment index ====================================== ...
And this is what i have done so far and i dont know where I am wrong ...
Code: #include<stdio.h> int main() { int index = 0; //initialize index to zero since first elementin an array is numbered zero char newstring[80];
I'm working my way through some C exercises to get some practice and have hit a wall. I need to use a function to take a number, such as 1, and print out One.Here's what I've got so far:
Code: #include <stdio.h> int name(int n); char numberOne[] = "One"; int main(void) { int n; }
[code]...
However, when I run the code and enter "1" the only thing that gets printed to the screen is "(lldb)". I've tried changing it to doing it without variables and just printing "One" but that gave the exact same result.
I have a text file where in each line is 3 words and 2 int type numbers. I'm doing search by word and I want to print out to the screen the whole line where that word was found (the words is repeated in some lines). My search looks like this:
Code: #include<iostream> #include<string> #include<fstream> #include<stdlib.h> #include <vector> using namespace std; int main(){ vector <string> words; string str, paieska;
Basically I have a text file called words. I'm supposed to extract a word randomly form the file and have the user guess the word. If they guess the word correctly in x number of tries they will receive the definition.
I'm having trouble receiving that random word and I'm getting the definitions from the file.
This is what is in the words.txt file apple#the usually round, red or yellow, edible fruit of a small tree boat#a vessel for transport by water horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding television#a system for transmitting visual images and sound that are reproduced on screens soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc. bottle#a container, typically made of glass or plastic and with a narrow neck barber#a person who cuts hair toast#sliced bread browned on both sides by exposure to radiant heat radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects red#of a color at the end of the spectrum next to orange and opposite violet
I am building a linked list and i need to display function i have. The display function displays all the letters of the word entered instead of the word itself. below is my struct, one of my functions and the display function.
I've taken part the text into 1 word per line, but I can't figure out how to printf every word only once and then add (%d) in the end to show how many repetitions of that word there are.
Code: #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; int main(){ char *oneword;
I have text (string) and I want to find a given word (it's ok!) and then insert another given word after the first word. The original string is beeing copied into a new string. But something is going wrong!!! Where is my mistake?
(I have some patches...)
Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> //insert "new_word" after each occurence of "word" int main(){ char A[100]="In the sentence words the and the.";
i'm making a program for basic data entry.i have also included search feature which uses strcmpi() function.if i have a file name'report on tigers' and someone searched for 'tigers' then that person will not find the required file.any way i can overcome that ?
I am making a program where the user enters numbers into an array and then a number,x. The array is sorted, then x is inserted into the appropriate place. I wrote my selection sort
Code:
void Sort(int ary[], int size) { int temp; int smallest; int current; int move; }
[code]....
put it wont print the numbers sorted when I use my print function, just the unsorted numbers.
So this is my homework: a user will enter a line of text, echo the input one word per line and capitalize each word(do not use toupper) and also needs word count and punctuation marks count. I know how to echo one word per line. How to capitalize each word without toupper? and how to do word count?
I was wondering if there is a way for me to break up a word compare it one character at a time and change it according to a real word like if you have cat and dog it would go from cat to bat, bat to bag, bag to bog, then bog to dog.
What the heck is wrong with my logic? I just print a rectangle!!! I have played with thing for ever it seems. I thought the rotating part would be hard but now I find myself stuck.