C/C++ :: Print More Strings (the Strings May Contain Spaces)?
Feb 12, 2014
I have a problem who must print the sentences who have lenght more than 20 characters. I dont know why, but it prints just the first words. Look what i made.
#include<stdio.h>
#include<conio.h>
int main()
[Code]....
For instance :
Give the number of sentences : 3
First sentence : I like the website bytes.com
Second sentence : I like more the website bytes.com
Third sentence : bytes.com
After I compile the program it should print the first two sentences.
View 2 Replies
ADVERTISEMENT
Aug 11, 2013
How I can manipulate certain strings. This program here is supposed to randomly scramble any word/sentence input. However, I notice that even the empty spaces get moved; is there any way to stop that from happening? I would want the empty spaces to stay in their input positions.
#include <iostream>
#include <string.h>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>
using namespace std;
[Code] ....
View 4 Replies
View Related
Feb 13, 2013
This is my program and i dont know what is the better strategy to display the output perfectly align with the title, when i input a long variable or short the variable move and it does not align with its title. what can i do.
#include <iostream>
#include <string>
#include <string.h>
#include <cstdlib>
#include <cstring>
#include <iomanip>
using namespace std;
struct book {
[Code] ....
View 1 Replies
View Related
Aug 2, 2013
I need to write a program that reads a paragraph from a file (i dont know its length) and i need to read it with spaces
i thought of using getline() function but there were problems:
1) how to detect End Of File
2) how to use getline while reading from file
and thought of reading one character at a time but it didnt read spaces
View 4 Replies
View Related
Mar 6, 2015
I am making a program that takes the user's family names, their ages, and where they live. At the end I will be eventually averaging out their age and also printing the names of anyone who lives in Kansas.
I can't seem to get the Kansas part to work properly though.. When I execute the code, everything else works perfectly, but the Kansas part doesn't even print. Is there something different I need to do when strings are involved rather than integers/floats?
Code:
#include <stdio.h>
int main ()
{
/* variable definition: */
[Code].....
View 6 Replies
View Related
Mar 24, 2015
I am making a program that takes the user's family names, their ages, and where they live. At the end I will be eventually averaging out their age and also printing the names of anyone who lives in Kansas.
I can't seem to get the Kansas part to work properly though.. When I execute the code, everything else works perfectly, but the Kansas part doesn't even print. Is there something different I need to do when strings are involved rather than integers/floats?
#include <stdio.h>
int main () {
/* variable definition: */
[Code].....
View 3 Replies
View Related
Aug 19, 2013
How to search in C or C++ a hexadecimal patterns within a binary file.
For example:
String1:
Code: 0x44 0x65 0x07
Then, once found, extract those 3 bytes and the next 11 bytes (14 bytes in total).
Finally, from those 14 bytes, print without spaces "bytes 1 to 6", "bytes 6 to 12", and byte "13 to 14".
Then I would like to print last 2 bytes (13 to 14) joined in decimal format.
The output without any conversion would be:
Code:
446507c90688 888000800005 0015
4465072ec918 059173495269 002C
44650700cc01 01811bc90b00 00AB
But the output converting to decimal the last 2 bytes would be:
Code:
446507c90688 888000800005 21
4465072ec918 059173495269 44
44650700cc01 01811bc90b00 171
The sample file is attached, and looks like this:
Code:
06 00 00 80 00 00 00 80 09 3c c9 06 88 88 80 00
80 00 44 65 07 c9 06 88 88 80 00 80 00 05 00 15
37 06 01 00 00 01 00 65 00 00 00 02 00 00 02 00
18 00 00 00 03 00 00 03 00 17 00 00 00 04 00 00
[Code] .....
View 8 Replies
View Related
Oct 29, 2014
This program is supposed to compare 2 strings and print out a 1 if the characters match and a 0 if they dont. It compiles but doesnt give me the correct output.
Code:
#include <stdio.h>
#include <string.h>
void func();
int main () {
func();
return 0;
[Code] ....
View 11 Replies
View Related
Dec 12, 2013
I'm very very new to maps and am really just trying to hash them out by myself.
If you're mapping strings to integers:
map <string, int> myMap;
myMap[ "zero" ] = 0;
myMap[ "one" ] = 1;
How do I print the string "zero", for instance, from myMap?
cout << myMap.at(0) << endl;
doesn't work. Nor does:
cout << static_cast<string>( myMap.at(0) ) << endl;
I need access to the string using the int and the int using the string. Or just direct access to one or the other. . . It's just confusing that they're technically mapped to one another but I can't really access either of them.
View 4 Replies
View Related
Feb 17, 2014
I am trying to print the array of string using this code but the compiler is printing null in the output:
The code is as follows:
char *arr[10];
int i;
for(i=0;i<10;i++)
scanf("%s",*(arr+i));
for(i=0;i<10;i++)
printf("%s
",*(arr+i));
View 3 Replies
View Related
Apr 7, 2013
I am programming a translator, and I have it so that it detects words with spaces both in front of and behind them, so I did "string.append(space);" where space equals " ". That added a space to the end, but I still need a space added to the front.
View 1 Replies
View Related
Sep 1, 2014
is there a to use printf to print certain number of blank spaces, where the number is derived from the output of a function?
for(m=low; m<=high;m++)
{
printf("t=%2d %'f(m)-1's %3c", m, ' ',*);
}
This is suppose to output
t=-3 *
t=-2 *
t=-1
.
.
.
View 2 Replies
View Related
Mar 12, 2013
Just working up for the google coding contest to start soon and have been practising some of the test questions however i make correct algorithms but my output is rejected because of the fact that my strings are printed on a new line so i wish to know a method to print strings using a printf statement or any other function on the same line ...
View 3 Replies
View Related
Apr 13, 2013
i am trying to write a program to print a statement without spaces in it.For example, if the statement is "Hello, i am Solidsnake", then it should print it as "Hello,iamsolidsnake".
View 4 Replies
View Related
Sep 1, 2014
is there a to use printf to print certain number of blank spaces, where the number is derived from the output of a function?
for(m=low; m<=high;m++)
{
printf("t=%2d %'f(m)-1's %3c
", m, ' ',*);
}
this is suppose to output
t=-3 *
t=-2 *
t=-1
.
.
.
This is supposed to output t=m and then m is plugged into a function say for -3, plugging it into function f gives 23, well i want 22 blank spaces and then a asterik and go to next line. that is why i put -1 after %'f(m)-1's i
The asterisk appear right next to the t value here but they are way to the right of it when i made this post.
View 2 Replies
View Related
Feb 26, 2014
I am having some trouble tokenizing some strings in C. I am trying to take in a string dynamically and spit print it to the console tokenized using the spaces as delimiters. I have tried using frets() and scant() as well as playing around with pointer values to no avail.
#include <stdio.h>
#include <unistd.h>
#include<string.h>
#include <stdlib.h>
#define MAX_LINE 80
//function prototypes
void printArgs(int argc, char* args[]);
[Code] .....
View 7 Replies
View Related
Nov 16, 2013
I tried to add 2 or more strings together but failed.
eg I would like to add "KK" & "LL" together by adding but it couldn't work.
string string_B = "KK";
string string_C = "LL";
string_A = string_B + string_C;
View 2 Replies
View Related
Mar 5, 2013
1. I finished reading a beginning C book, and in the section about arrays, it says that one string can fit in a character array (char arrayname[]) but there cannot be a string array (string arrayname[]) that have multiple strings. Is
Code: string arrayname[4] = {"one", "two", "three"}; not valid?
My compiler lets me run it and it works, but why is the book saying it's wrong?
2. I know you can represent multiple strings in a character array by:
Code: char newarray[10][4] = ("one", "two", "three");
because [10][4] indicates that there should be four newarrays created with a max of 10 characters each, but is
Code: string multiplestrings[10][4] = ("i love you", "hello come to me", "i don't get C"; "hello world", "what are arrays"; "i am happy", "I am learning how to code"); valid?
Does multiplestrings[10][4] basically create 4 string arrays that have a maximum of 10 different strings within each string array?
View 6 Replies
View Related
Dec 14, 2014
How join two strings? basic reason is add given filename little text to end. I try do by hobby not school project program which converts files format x to format y.i dont say which formats becouse reading and writing is almost done. (only little amount code is needed).'
View 2 Replies
View Related
Feb 9, 2015
javascript:tx('quote')
void family () {
string father;
string mother;
string kids;
int x;
int y=0;
[Code] .....
How am I allowed to but the 3 strings father, mother and kids in a array?
View 3 Replies
View Related
Mar 26, 2014
None of my string is coming out onto my output file..
void OutputHeading (ofstream& fout, string CLASS_EXERCISE,
string PROGRAMMERS_NAME);
void OutputDivider (ofstream& fout, int WIDTH,
char symbol);
void OpenFiles (ofstream& fout, ifstream& fin);
[Code] .....
View 1 Replies
View Related
Jul 3, 2013
I've got a very simple but annoying problem.
if (letter3=="
"){
letter3==letter;
PrintCharacterLineEnd();
This is a code. the string "letter3" contains the string "
". What I want to happen is when, letter3 contains the text "
" I want to go to the function PrintCharacterLineEnd.
However, as of right now it's not working.
View 14 Replies
View Related
May 19, 2013
I need to make a small program with a function with this prototype: void f(char *a,char *b) that adds two numbers represented as strings without using conversion operators or other tricks.
View 17 Replies
View Related
Apr 10, 2013
why all strings are always constant?
View 2 Replies
View Related
Apr 19, 2012
I have a vector I want to add book titles to, then i want to print my updated vector. This is best I have come up with but the program fails at the getline line. why?
string book;
cout << "Enter book to add: "<< endl;
getline(cin, book);
books.push_back(book);
for(int i = 0; i < books.size(); ++i) {
cout << i+1 << ". " << books[i] << endl;
}
View 1 Replies
View Related
May 3, 2012
The problem with this code is that there are no errors showing, but when i compile the program, the if else statements do not carry out as they should do. Both if statements show the same answer, for example the second if statement. If I type Y or N then I get the same thing, 'You will now choose an event'. How do i get rid of this problem? Is char supposed to be used or string?
#include <iostream>
#include <iomanip>
#include<stdlib.h>
[Code].....
View 1 Replies
View Related