C++ :: How To Put Strings Into Arrays
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
Apr 10, 2013
What is the diff between strings and arrays? Here is sample:
By String:
#include <iostream>
#include <string>
using namespace std;
int main () {
string mystr;
[Code] .....
By arrays:
#include <iostream>
using namespace std;
int main () {
char name[256], title[256];
[Code] ....
which is preferable and can i pick characters one by one in string?
View 2 Replies
View Related
Oct 25, 2014
You will have two file streams: an input file stream for the file to be normalized and an output file stream that contains the normalized file. You should issue an error message and exit the program if either file cannot be opened. Your program should prompt the user for the filename of the file to be normalized (the input file). The output filename should be the input filename with ".normal" added to it. For example, if the input file is "data.txt", the output file name will be "data.txt.normal".
Be careful to not leave an extra blank line at the end of your output file.
My question here is how do I rename the file that the user entered to have a ".normal" at the end of it? I was thinking along the lines of having to string names and changing the second string's name and use that as the output file. any examples cause I didn't exactly get that to work.
#include <iostream>
#include <fstream>
#include <string>
[Code]....
View 8 Replies
View Related
Dec 9, 2014
how do I tell the if statement to output this error message 'exceeded the maximum amount of characters' that has its characters stored in an array using c-style string?
[INPUT] The cat caught the mouse!
[OUTPUT] Exceeded the maximum amount of characters (max 10)
#include<iostream>
#include<string>
[Code]....
View 2 Replies
View Related
Jan 9, 2015
I have a firmware application that works well where I display simple text messages on an LCD screen. At the moment, the User Interface is only in English and I have the text strings simply declared as follows:
Code:
static char msg1[] = " Welcome ";
static char msg2[] = " Data Read ";
//etc...
I want to add a variable that can set the language dynamically from an external device, and so I thought I could do the following:
Code:
#define ENG 0
#define FRE 1
#define GER 2
//...
static char msg1[ENG][] = " Welcome ";
static char msg2[ENG][] = " Data Read ";
[Code] .....
writeLCD(msg1[cLang][]); When I try to compile the above I get a compiler error at the "static char msg..." declarations. The error is: "error: array type has incomplete element type"
Is this method valid, but I have a simple syntax problem with the arrray declarations? Or is this method unworkable and I should find a different method?
View 6 Replies
View Related
May 7, 2013
I previously tried to put strings in an array, but i couldn't modify the first index in the string that is in the array. I changed my code later.
[URL]
Suggest a function that sorts the inputs vertically according to the order given by the user? I made this one
void order(string order, char index[][15]){
int counter=0,line=0,i=0,j=0;
for(i=0;i<=15-1;i++)
{for(j=0;j<=15-1;j++) {
if(index[j][i]==order[counter])
[code].....
View 1 Replies
View Related
Nov 11, 2014
My assignment is writing Madd Libs game. I still do not understand how to store inputted strings or values to arrays. I need explanation of collecting inputted data to arrays.
#include "stdafx.h"
#include<stdio.h>
//#include<string.h>
int main(void) {
char string[37] = {'