i wish to get different combination from a String. For example: String^ str = "a,b,c,d,e";
i will wan to separate the string into individual letters and form all different combination like (a,b), (a,c,d) or (a,b,c,d) etc..
is there any simple methods to do so juz using loop?? im still a beginner in C++ so i dun really noe any built in methods. But if haf i will wish to learn too. pls help!! thx
Combination of String in C++?
I know of no easy way of doing the task you want to accomplish using a built in library function of C/C++. Basically, there are a few things you will need to do:
1. Parse out each of the comma separated characters and create a set containing each of those characters (this set could be stored in an array of chars).
2. Print the power set of the character set you have. The power set is the formal name for what you are looking to print. A simple algorithm for this would be to start with the first element in your list and combine that with each of the characters after it. Once all combinations involving the first character have been exhausted, move on to the second but only do combinations of the second not involving the first character which came before it. Do this for each character in the set and your task will be accomplished.
This problem is ripe for recursion if you are so inclined.
Tuesday, July 14, 2009
String manipulation C++?
Hi i am working on a small program where a user enters a string which should be more than 8 characters. Then once they have entered a string, the program should do the following:
1) output the size of the sentence
2) output the 1st 3rd 5th and 7th letter and append it to the end of the inputted sentence.
This is what i have done so far but i am getting errors and i am new to c++:
#include %26lt;iostream%26gt;
#include %26lt;string.h%26gt;
#include %26lt;sstream%26gt;
using namespace std;
int main()
{
int iQuit;
char str[7];
cout%26lt;%26lt; "Enter sentence \n";
getline(cin,str);
cout%26lt;%26lt; "Size of the sentence" %26lt;%26lt; str.length() %26lt;%26lt; endl;
cin %26gt;%26gt; iQuit;
return 0;
}
Can someone help on this and the second part please? i could probably do this in java but i need to do in C++.
I would appreciate it if someone can help me on tell me they have done in such a way?
String manipulation C++?
There are two main kinds of string in C++, the null terminated strings inherited from C and the C++ string object. Using the latter makes your assignment a cinch. Unless you are instructed otherwise you should begin to use string objects and move away from null terminated strings whenever possible.
#include %26lt;iostream%26gt;
#include %26lt;string%26gt;
using namespace std;
int main()
{
string input;
while (input.length() %26lt;= 8)
{
cout%26lt;%26lt; "Enter sentence at least 8 characters in length\n";
getline(cin, input);
}
cout%26lt;%26lt; "Size of the sentence = " %26lt;%26lt; input.length() %26lt;%26lt; endl;
input += input[2];
input += input[4];
input += input[6];
cout %26lt;%26lt; "appended sentence is: " %26lt;%26lt; input %26lt;%26lt; endl;
return(0);
}
Reply:Try this code for starters. Can you spot the changes?
#include %26lt;iostream%26gt;
#include %26lt;string.h%26gt;
#include %26lt;sstream%26gt;
using namespace std;
int main()
{
int iQuit;
string input;
cout%26lt;%26lt; "Enter sentence \n";
getline(cin, input);
cout%26lt;%26lt; "Size of the sentence " %26lt;%26lt; input.length() %26lt;%26lt; endl;
cin %26gt;%26gt; iQuit;
return 0;
}
Reply:You can't say str.length(). You have to use the function strlen(), like this:
cout%26lt;%26lt; "Size of the sentence" %26lt;%26lt; strlen(str) %26lt;%26lt; endl;
To output the 1st, 3rd, 5th and 7th letters you have to access them from the string/character-array. This is done like so: str[0] is the 1st. str[2] is the 3rd letter, etc.
Appending is easy. Just make a new character array that is bigger, copy the inputted string to it (using the strcpy function) and then assign the letters that you want to the new string.
forsythia
1) output the size of the sentence
2) output the 1st 3rd 5th and 7th letter and append it to the end of the inputted sentence.
This is what i have done so far but i am getting errors and i am new to c++:
#include %26lt;iostream%26gt;
#include %26lt;string.h%26gt;
#include %26lt;sstream%26gt;
using namespace std;
int main()
{
int iQuit;
char str[7];
cout%26lt;%26lt; "Enter sentence \n";
getline(cin,str);
cout%26lt;%26lt; "Size of the sentence" %26lt;%26lt; str.length() %26lt;%26lt; endl;
cin %26gt;%26gt; iQuit;
return 0;
}
Can someone help on this and the second part please? i could probably do this in java but i need to do in C++.
I would appreciate it if someone can help me on tell me they have done in such a way?
String manipulation C++?
There are two main kinds of string in C++, the null terminated strings inherited from C and the C++ string object. Using the latter makes your assignment a cinch. Unless you are instructed otherwise you should begin to use string objects and move away from null terminated strings whenever possible.
#include %26lt;iostream%26gt;
#include %26lt;string%26gt;
using namespace std;
int main()
{
string input;
while (input.length() %26lt;= 8)
{
cout%26lt;%26lt; "Enter sentence at least 8 characters in length\n";
getline(cin, input);
}
cout%26lt;%26lt; "Size of the sentence = " %26lt;%26lt; input.length() %26lt;%26lt; endl;
input += input[2];
input += input[4];
input += input[6];
cout %26lt;%26lt; "appended sentence is: " %26lt;%26lt; input %26lt;%26lt; endl;
return(0);
}
Reply:Try this code for starters. Can you spot the changes?
#include %26lt;iostream%26gt;
#include %26lt;string.h%26gt;
#include %26lt;sstream%26gt;
using namespace std;
int main()
{
int iQuit;
string input;
cout%26lt;%26lt; "Enter sentence \n";
getline(cin, input);
cout%26lt;%26lt; "Size of the sentence " %26lt;%26lt; input.length() %26lt;%26lt; endl;
cin %26gt;%26gt; iQuit;
return 0;
}
Reply:You can't say str.length(). You have to use the function strlen(), like this:
cout%26lt;%26lt; "Size of the sentence" %26lt;%26lt; strlen(str) %26lt;%26lt; endl;
To output the 1st, 3rd, 5th and 7th letters you have to access them from the string/character-array. This is done like so: str[0] is the 1st. str[2] is the 3rd letter, etc.
Appending is easy. Just make a new character array that is bigger, copy the inputted string to it (using the strcpy function) and then assign the letters that you want to the new string.
forsythia
C++ programing, this is my study guide can you help me get the right answers?
1. Making a variable behave like a variable of a different data type is known as
a.typecasting
b.brute force
c.intimidation
d.variable casting
2. To redirect the input for a C++ program (theprog.exe) to come from a file rather than the keyboard you would:
a.theprog %26lt; infile.txt
b.theprog %26lt;%26lt; infile.txt
c.theprog %26gt; infile.txt
d.theprog %26gt;%26gt; infile.txt
3. if a do/while structure is used,
a) an infinite loop will not take place
b) counter controlled repetition is not possible
c) the body of the loop will execute at least once
d) an off-by-one error will not occur
4. A function prototype does not have to
a)include parameter names
b)terminate with a semicolon
c)agree with the function definition
d)match with all calls to the function
5. A function prototype does not have to
a)include parameter names
b)terminate with a semicolon
c)agree with the function definition
d)match with all calls to the function
6. For command line arguments you write your main function:
int main(int argc, char *argv[])
The argc refers to:
a.the count of the arguments passed
b.an array of pointers to strings
c.the number of people using the program
d.the size in bytes of the program
C++ programing, this is my study guide can you help me get the right answers?
1. a.
2. d.
3. c.
4. d.
5. isn't this #4?
6. a.
Reply:1. a
2. a -- I think
3. c
4.a - i think
5. same as 4 ?
6. a
Number 4 - example of prototype
void function(int number) will work if you do this as well
void function(int) I don't think poster above said it right
I know this will work.
Man whoever gave you the study guide -- really likes a answers :)
number 2 - site below answers the question. And thats what I thought before I went and looked, so I am right
a.typecasting
b.brute force
c.intimidation
d.variable casting
2. To redirect the input for a C++ program (theprog.exe) to come from a file rather than the keyboard you would:
a.theprog %26lt; infile.txt
b.theprog %26lt;%26lt; infile.txt
c.theprog %26gt; infile.txt
d.theprog %26gt;%26gt; infile.txt
3. if a do/while structure is used,
a) an infinite loop will not take place
b) counter controlled repetition is not possible
c) the body of the loop will execute at least once
d) an off-by-one error will not occur
4. A function prototype does not have to
a)include parameter names
b)terminate with a semicolon
c)agree with the function definition
d)match with all calls to the function
5. A function prototype does not have to
a)include parameter names
b)terminate with a semicolon
c)agree with the function definition
d)match with all calls to the function
6. For command line arguments you write your main function:
int main(int argc, char *argv[])
The argc refers to:
a.the count of the arguments passed
b.an array of pointers to strings
c.the number of people using the program
d.the size in bytes of the program
C++ programing, this is my study guide can you help me get the right answers?
1. a.
2. d.
3. c.
4. d.
5. isn't this #4?
6. a.
Reply:1. a
2. a -- I think
3. c
4.a - i think
5. same as 4 ?
6. a
Number 4 - example of prototype
void function(int number) will work if you do this as well
void function(int) I don't think poster above said it right
I know this will work.
Man whoever gave you the study guide -- really likes a answers :)
number 2 - site below answers the question. And thats what I thought before I went and looked, so I am right
C++ prog. Problems with a String class. (the same as in my previous question): what's wrong with it? copy fct?
.h::::::::::::::::::::::::::::::::::::::...
#ifndef STRING_H
#define STRING_H
#include %26lt;iostream%26gt;
namespace HomeMadeString
{
class String
{
unsigned int elementsNum;
char*pData;
public:
String()
{
elementsNum=0;
char*pData=NULL;
}
String(String %26amp;theOther);
String(const char* c1);
String(char c, unsigned int times);
~String()
{
delete[] pData;
}
void getStr(char * pBuff);
unsigned int getLength(){return elementsNum;}
void print(std::ostream%26amp; os);
char getChar(unsigned int pos);
static String concatenate(String string1, String string2);
static bool compare(String string1, String string2);
static void copy(String%26amp; string1, String string2);//it copies the second string into the first
};
}
#endif
.cpp::::::::::::::::::::::::::::::::
How to write the "copy" function?
The "print" function?
Please help!
Domonkos
C++ prog. Problems with a String class. (the same as in my previous question): what's wrong with it? copy fct?
You get that char*pData inside your constructor is a separate declaration, it does not reference the class-scope variable with the same name (and it falls out of scope when the constructor returns.
Also, your code is conspicuously lacking any allocations -- don't rely on memory allocated by the caller, it could go away at any time.
More, avoid implementation inside of the .h file, it will bite you in the butt when your projects become complex.
Copying an object is usually done as a self-referential overload of the constructor, accepts parameter of its own class.
Not sure what you want print() to do, print to a printer? Doesn't seem to make much sense. If you mean print to console, what's wrong with printf() or stream output?
Good Luck
#ifndef STRING_H
#define STRING_H
#include %26lt;iostream%26gt;
namespace HomeMadeString
{
class String
{
unsigned int elementsNum;
char*pData;
public:
String()
{
elementsNum=0;
char*pData=NULL;
}
String(String %26amp;theOther);
String(const char* c1);
String(char c, unsigned int times);
~String()
{
delete[] pData;
}
void getStr(char * pBuff);
unsigned int getLength(){return elementsNum;}
void print(std::ostream%26amp; os);
char getChar(unsigned int pos);
static String concatenate(String string1, String string2);
static bool compare(String string1, String string2);
static void copy(String%26amp; string1, String string2);//it copies the second string into the first
};
}
#endif
.cpp::::::::::::::::::::::::::::::::
How to write the "copy" function?
The "print" function?
Please help!
Domonkos
C++ prog. Problems with a String class. (the same as in my previous question): what's wrong with it? copy fct?
You get that char*pData inside your constructor is a separate declaration, it does not reference the class-scope variable with the same name (and it falls out of scope when the constructor returns.
Also, your code is conspicuously lacking any allocations -- don't rely on memory allocated by the caller, it could go away at any time.
More, avoid implementation inside of the .h file, it will bite you in the butt when your projects become complex.
Copying an object is usually done as a self-referential overload of the constructor, accepts parameter of its own class.
Not sure what you want print() to do, print to a printer? Doesn't seem to make much sense. If you mean print to console, what's wrong with printf() or stream output?
Good Luck
C++ study guide help?
1.Which of the following can contain data items of different types?
a.an array
b.a structure
c.a string
d.none of the above; they can only contain different values
2.For a main function defined as following:
void main(int argc, char * argv[])
Which statement below is NOT correct?
a.The first argument tells how many separate arguments were passed.
b.The second argument represents an array of strings.
c.The first (i.e. the 0th) argument is the name of the program
d.The first (i.e. the 1st) argument is the name of the program
e.none of the above
3.In C++, all variables
a.take up the same amount of storage on a certain computer type
b.take up the same amount of storage on all computer types
c.take up different amounts of storage depending on the data type
d.take up different amounts of storage depending on the length of the variable name
4.Every element of any array takes up one byte in memory
a.true
b.false
5.In object oriented programming the constructor
a.is the method called when you create an instance of that class
b.has the same name as the name of the class
c.is used to initialize variables
d.all of the above
C++ study guide help?
1-a , 2-e(maybe) 3-c 4-b 5-d
a.an array
b.a structure
c.a string
d.none of the above; they can only contain different values
2.For a main function defined as following:
void main(int argc, char * argv[])
Which statement below is NOT correct?
a.The first argument tells how many separate arguments were passed.
b.The second argument represents an array of strings.
c.The first (i.e. the 0th) argument is the name of the program
d.The first (i.e. the 1st) argument is the name of the program
e.none of the above
3.In C++, all variables
a.take up the same amount of storage on a certain computer type
b.take up the same amount of storage on all computer types
c.take up different amounts of storage depending on the data type
d.take up different amounts of storage depending on the length of the variable name
4.Every element of any array takes up one byte in memory
a.true
b.false
5.In object oriented programming the constructor
a.is the method called when you create an instance of that class
b.has the same name as the name of the class
c.is used to initialize variables
d.all of the above
C++ study guide help?
1-a , 2-e(maybe) 3-c 4-b 5-d
ASP 2.0 C# Access Connection String?
Can someone post a sample connection string to connect to an Access mdb file (not using SQL) in C#? I am using ASP.NET 2.0, but can only find SQL connection strings. Thanks.
ASP 2.0 C# Access Connection String?
http://www.carlprothman.net/Default.aspx...
You will always use a SQL statement to gather your info from the db.
Reply:Here is a sample.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\rebuilt.MDB
You can click on the top menu "tools" selection and select
"Connect to Database..." Select "Microsoft Access Database File", click Continue, browse to the database to open, and the connection will be added to your project.
jasmine
ASP 2.0 C# Access Connection String?
http://www.carlprothman.net/Default.aspx...
You will always use a SQL statement to gather your info from the db.
Reply:Here is a sample.
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data\rebuilt.MDB
You can click on the top menu "tools" selection and select
"Connect to Database..." Select "Microsoft Access Database File", click Continue, browse to the database to open, and the connection will be added to your project.
jasmine
Is there any situation in which it would be useful to create a matrix of bools or string in C++?
Lets say we have a Matrix program in C++, and we are using template, I want to know if you have an example of a situation in which it would be useful to create a matrix of bools. How about a matrix of strings?
Is there any situation in which it would be useful to create a matrix of bools or string in C++?
mmm.. yeah... think about it. name yes/no
Reply:a matrix of bools could represent a very simple bitmap (in black/white), or possibly a map of some kind that indicates specific points of interest.
if it's a sparse-matrix, then you can get away with simulating it using a chained hashtable, which will save memory %26amp; time.
Is there any situation in which it would be useful to create a matrix of bools or string in C++?
mmm.. yeah... think about it. name yes/no
Reply:a matrix of bools could represent a very simple bitmap (in black/white), or possibly a map of some kind that indicates specific points of interest.
if it's a sparse-matrix, then you can get away with simulating it using a chained hashtable, which will save memory %26amp; time.
Physics Help -Three Pulling Strings - Please Quick?
Three strings, in the horizontal plane, meet in a knot and are pulled with three forces such that the knot is held stationary. The tension in string 1 is T1 = 2.1 N. The angle between strings 1 and 2 is q12 = 130� and the angle between strings 1 and 3 is q13 = 120� with string 3 below string 1 as shown.
a) Find the tension in string 2.
T2 = N
b) Find the tension in string 3.
T3 = N
A mass of 1.1 kg is now placed on the knot and supported by a frictionless table in the plane of the strings. c) Find the acceleration of the mass if all the forces remain the same as above.
|a| = m/s2
d) If the sizes and directions of T2 and T3 remain the same, but T1 is increased by 2.4 N, what is the acceleration of the mass?
|a'| = m/s2
Physics Help -Three Pulling Strings - Please Quick?
The knot is held stationary =%26gt; T1 + T2 + T3 = 0(in vector)
=%26gt; Consider reference frame Oxy with: Ox - direction of string 1, Oy - perpendicular with string 1.
=%26gt; Ox: T1 - T2*cos50 - T3*cos60 = 0
Oy: T2* sin50 - T3 *sin60 = 0
=%26gt; T2 = T1/[(cot50 + cot60)*sin50] = 2.3N
T3 = T1/[(cot50 + cot60)*sin60] = 2.0N
All the forces remain the same =%26gt; net force is 0 =%26gt; a = 0
T2 and T3 remain the same, T1 increase be 2.4N =%26gt; net force F = 2.4N =%26gt; a = F/m = 2.2 m/s2
a) Find the tension in string 2.
T2 = N
b) Find the tension in string 3.
T3 = N
A mass of 1.1 kg is now placed on the knot and supported by a frictionless table in the plane of the strings. c) Find the acceleration of the mass if all the forces remain the same as above.
|a| = m/s2
d) If the sizes and directions of T2 and T3 remain the same, but T1 is increased by 2.4 N, what is the acceleration of the mass?
|a'| = m/s2
Physics Help -Three Pulling Strings - Please Quick?
The knot is held stationary =%26gt; T1 + T2 + T3 = 0(in vector)
=%26gt; Consider reference frame Oxy with: Ox - direction of string 1, Oy - perpendicular with string 1.
=%26gt; Ox: T1 - T2*cos50 - T3*cos60 = 0
Oy: T2* sin50 - T3 *sin60 = 0
=%26gt; T2 = T1/[(cot50 + cot60)*sin50] = 2.3N
T3 = T1/[(cot50 + cot60)*sin60] = 2.0N
All the forces remain the same =%26gt; net force is 0 =%26gt; a = 0
T2 and T3 remain the same, T1 increase be 2.4N =%26gt; net force F = 2.4N =%26gt; a = F/m = 2.2 m/s2
Can you tune a violin to include a C string?
You mean to add another string or, for example, just tune a A to C? If it's the latter, yes it's doable... but why would you want to?
Can you tune a violin to include a C string?
Custom 5-string Violin? Yes.
Can you tune a violin to include a C string?
Custom 5-string Violin? Yes.
Ladies: would you or have you tried the C String?
heres the link
https://www.cstringdirect.com/
Ladies: would you or have you tried the C String?
lmao..
i think every lady needs one in her closet !
Reply:you are going to find it under your christmas tree
:) Report It
Reply:Maybe
I would be interested only if I was given one
Can you say Yeast Infection....
Ssshhhh holla ;P
Reply:Havent tried and I dont wear panties so its not a problem for me. lmao
Reply:it looks like a pad....im sory, it does.
heck no
Reply:I don't get it. How does it stay in place? And how did you come across this interesting invention?
Reply:Why bother? Might as well go commando!
Reply:that looks interesting
MO
Reply:Wow...and what is the point of wearing anything at all??? To catch the discharge??? GROSS. It's doesn't even look comfy. It looks like it would be shifting all day long.
Reply:no
Reply:Hmmm, nope, never even heard of that one! We are so sheltered here in the midwest! lol Not sure about all that, kinda looks like a headband for your ummm.... lol
Reply:It looks like a headband...I wonder if thats how they came up with it. Just stuck a headband there. lmao!!
No.
Have not.
%26amp; probably wont.
Reply:how much would you pay me to try it on.
Reply:No, I might as well not wear any underwear
Reply:No! They look uncomfortable and tight, probably plastic under there or something to keep shape. They don't look that sexy either. It looks like a pad.
Reply:No and No.
It looks like it would fall off.
Is there even anything on the back?
I am going to pass on that one.
(( %26lt;3 Bella %26lt;3 ))
Reply:You know I will try anything once. Let me know when to schedule my fitting.
Reply:Thank you, i just found what the other half is getting for Christmas lol
Reply:No way!! I'll stay w/ the G string. Seems like the C string may slip and slide a little bit.
Reply:no, i haven't. i wouldn't either. i don't know. that's a little too far out there.
Reply:wow %26gt;:) *evil grin*
Reply:How does it stay up? It doesn't look like there are any strings? What if you had to run to catch the bus? It looks like the new style of earmuffs they have out ...? I going to pass on those......?
Reply:I never have, but I might- I usually don't wear any panties.
Reply:Wow. My contacts sometimes show me the most interesting things.
I'm sorry. Carry on.
Reply:OMG no thank you.
well maybe... it depends... like if i was going out and i was wearing a dress but not for everyday use. so i would probably try it.
Reply:no, i'll stick with my long underwear..
Reply:I have this mental image:
Running to catch bus. Everyone staring at me as someone yells: "Oh Ma'am, you dropped your uh....uh......uh yuh..something, " as twenty people point %26amp; laugh.
Reply:no, thats like wearing a pad with no underwear lmao
Reply:No but maybe for you babe! LOL! =) ♥
Reply:Wow that thing is pointless why would I wear a pad seriously that is not sexy it all i would definitely not wear that i will stay with my G strings, thanks but that is a big no no there...
Reply:just...wow...
crab apple
https://www.cstringdirect.com/
Ladies: would you or have you tried the C String?
lmao..
i think every lady needs one in her closet !
Reply:you are going to find it under your christmas tree
:) Report It
Reply:Maybe
I would be interested only if I was given one
Can you say Yeast Infection....
Ssshhhh holla ;P
Reply:Havent tried and I dont wear panties so its not a problem for me. lmao
Reply:it looks like a pad....im sory, it does.
heck no
Reply:I don't get it. How does it stay in place? And how did you come across this interesting invention?
Reply:Why bother? Might as well go commando!
Reply:that looks interesting
MO
Reply:Wow...and what is the point of wearing anything at all??? To catch the discharge??? GROSS. It's doesn't even look comfy. It looks like it would be shifting all day long.
Reply:no
Reply:Hmmm, nope, never even heard of that one! We are so sheltered here in the midwest! lol Not sure about all that, kinda looks like a headband for your ummm.... lol
Reply:It looks like a headband...I wonder if thats how they came up with it. Just stuck a headband there. lmao!!
No.
Have not.
%26amp; probably wont.
Reply:how much would you pay me to try it on.
Reply:No, I might as well not wear any underwear
Reply:No! They look uncomfortable and tight, probably plastic under there or something to keep shape. They don't look that sexy either. It looks like a pad.
Reply:No and No.
It looks like it would fall off.
Is there even anything on the back?
I am going to pass on that one.
(( %26lt;3 Bella %26lt;3 ))
Reply:You know I will try anything once. Let me know when to schedule my fitting.
Reply:Thank you, i just found what the other half is getting for Christmas lol
Reply:No way!! I'll stay w/ the G string. Seems like the C string may slip and slide a little bit.
Reply:no, i haven't. i wouldn't either. i don't know. that's a little too far out there.
Reply:wow %26gt;:) *evil grin*
Reply:How does it stay up? It doesn't look like there are any strings? What if you had to run to catch the bus? It looks like the new style of earmuffs they have out ...? I going to pass on those......?
Reply:I never have, but I might- I usually don't wear any panties.
Reply:Wow. My contacts sometimes show me the most interesting things.
I'm sorry. Carry on.
Reply:OMG no thank you.
well maybe... it depends... like if i was going out and i was wearing a dress but not for everyday use. so i would probably try it.
Reply:no, i'll stick with my long underwear..
Reply:I have this mental image:
Running to catch bus. Everyone staring at me as someone yells: "Oh Ma'am, you dropped your uh....uh......uh yuh..something, " as twenty people point %26amp; laugh.
Reply:no, thats like wearing a pad with no underwear lmao
Reply:No but maybe for you babe! LOL! =) ♥
Reply:Wow that thing is pointless why would I wear a pad seriously that is not sexy it all i would definitely not wear that i will stay with my G strings, thanks but that is a big no no there...
Reply:just...wow...
crab apple
Would you go commando or wear a c-string?
Definitely commando: never wear the stuff, don't own any. Men are better off without underwear
Would you go commando or wear a c-string?
I usually go commando, depending on where I am going. If its the store, mall, outlet.. mail box, I go commando. If its a doc appt, hospital visit, I wear my undies.
Would you go commando or wear a c-string?
I usually go commando, depending on where I am going. If its the store, mall, outlet.. mail box, I go commando. If its a doc appt, hospital visit, I wear my undies.
B.C. Rich Warlock string help...?
Alright, so as you saw I have a B.C. Rich Bronze Series Warlock guitar (red). I got it a little while ago, and just today one of my strings broke. It was the e (thinnest) string. I need help with getting it replaced. I'm a beginner and this is my first electric guitar. I read online that some some strings break real easily on it, so I need a kind of string that won't =]. Can I do it by myself or should I give it to the store? If I do it myself (which I'll probably get the previous owner of the guitar to do it for me) what kind of strings should I buy? Name, place available, and price please. Thanks a lot guys!!!
P.S. I know this is silly but I have no idea what I'm doing, except for playing, with a guitar. =D
B.C. Rich Warlock string help...?
High Es (9s or 10s) can break a lot, because they are a thin gauge and you might strike them hard... Go to a shop and buy a bunch. They should only be about 25 cents each.
P.S. I know this is silly but I have no idea what I'm doing, except for playing, with a guitar. =D
B.C. Rich Warlock string help...?
High Es (9s or 10s) can break a lot, because they are a thin gauge and you might strike them hard... Go to a shop and buy a bunch. They should only be about 25 cents each.
Whats better to look for...a g-string or a c-string?
A C-string. Though they're ususally pretty thick - it's kind of hard to break one. Rosin-coated?
Whats better to look for...a g-string or a c-string?
LOL....funny..of course a G string.
Reply:how about a v-string? ;)
Reply:I prefer a pearl v string form fredericks of hollywood
Reply:If I were a lady, my wardrobe would have the complete array of g-strings, v-strings and c-strings. C-strings are a very important and exciting fashion innovation and I'm glad my girlfriend has a nice set of them.
Whats better to look for...a g-string or a c-string?
LOL....funny..of course a G string.
Reply:how about a v-string? ;)
Reply:I prefer a pearl v string form fredericks of hollywood
Reply:If I were a lady, my wardrobe would have the complete array of g-strings, v-strings and c-strings. C-strings are a very important and exciting fashion innovation and I'm glad my girlfriend has a nice set of them.
What's the standard functions for string process in C++?
I'm learning C++ programming. In my textbook, I only find some function for string processing such as "strcmp" or "strcat". But they are more widely used in old C. I want to know some newer function for string in C++, which process strings as "objects"?
If you know, tell me in detail (examples are best), Plz! Thanx.
What's the standard functions for string process in C++?
See: http://cplusplus.com/reference/string/st...
The page above describes what a string object is in C++ and gives details on its member functions and avaliable operations.
For example, assume:
std::string a = "Test"
std::string b = "Example"
Then, strcmp and strcat in C++ with string objects would be:
if ( a == b ) a+= b;
That is, if a is the same as B ( value wise ) then make a's value the sum of the value of a and b ("TestExample")
strawberry
If you know, tell me in detail (examples are best), Plz! Thanx.
What's the standard functions for string process in C++?
See: http://cplusplus.com/reference/string/st...
The page above describes what a string object is in C++ and gives details on its member functions and avaliable operations.
For example, assume:
std::string a = "Test"
std::string b = "Example"
Then, strcmp and strcat in C++ with string objects would be:
if ( a == b ) a+= b;
That is, if a is the same as B ( value wise ) then make a's value the sum of the value of a and b ("TestExample")
strawberry
C++ string question?
a program that takes an input string from the user and outputs as a single string, the first word following the first comma, the second word following the second exclamation point and the third word following the first semi-colon.
For example if the input string is:
?; Moon? Area! Formula, Precision; Label! First? Last! Text
The result would be
Precision Last Formula can u pls pls give me some ideas or codes to do it?ty
C++ string question?
Search for the first comma and then get back until you will find a space, and write on the screen the characters. Do the same for others.
For example if the input string is:
?; Moon? Area! Formula, Precision; Label! First? Last! Text
The result would be
Precision Last Formula can u pls pls give me some ideas or codes to do it?ty
C++ string question?
Search for the first comma and then get back until you will find a space, and write on the screen the characters. Do the same for others.
C++ string?
write a program that reads into a string object a name with three blanks between the first and last names. Then extract the first and last names and store them in separate string objects. write a function subproram that displays its string argument two times. call this function to display the first name four times and then to display the last name six times
C++ string?
Check out this site:
http://www.mochima.com/tutorials/strings...
It's got a tutorial that will show you how to do everything you need to do for your assignment!
C++ string?
Check out this site:
http://www.mochima.com/tutorials/strings...
It's got a tutorial that will show you how to do everything you need to do for your assignment!
C++ string help?
I need the user to input:
-the name of the file to read from
-name a file to be created to output the data
Ignoring the rest of the program, here is the part i'm having problems with:
#include %26lt;string%26gt;
int main()
{
// Filenames
string inFilename = "";
string outFilename = "";
// For file I/O
ifstream fin; //input file stream
ofstream fout; //output file stream
//User input of file name
cout%26lt;%26lt;"Enter the name of the input file: ";
getline(cin,inFilename);
//Works fine at this point, and opens the named file
//User input of file name
cout%26lt;%26lt;"Enter the new filename: ";
cin%26gt;%26gt;outFilename;
getline(cin,outFilename);
return 0;
}
When I compile I get no errors, but when I run the program, it will open the original file fine, but the output file won't pass the validity check, and won't even output the name of the file I had the user input in the error code as called for. What is the difference between the two!?!??!
C++ string help?
Actually, I don't see how that code is doing what you want. Try this;
std::string infilename;
std::string outfilename:
int main()
{
std::cout%26lt;%26lt;"please enter file to be opened"%26lt;%26lt;std::endl;
std::cin%26gt;%26gt;infilename;
fstream in(infilename.c_str(), ios::in);
if (in.good())
{
std::cout%26lt;%26lt;"file opening successful....."%26lt;%26lt;std::endl;
}
else if(in.bad())
{
std::cout%26lt;%26lt;" file opening failure....."%26lt;%26lt;std::endl;
return 0;
}
std::cout%26lt;%26lt;"please enter output filename"%26lt;%26lt;std::endl;
std::cin%26gt;%26gt;outfilename;
ofstream out(outfilename.c_str(), ios::out);
out%26lt;%26lt;"hi, I'm writing to this file!"%26lt;%26lt;std::endl;
in.close();
out.close();
return 0;
}
-the name of the file to read from
-name a file to be created to output the data
Ignoring the rest of the program, here is the part i'm having problems with:
#include %26lt;string%26gt;
int main()
{
// Filenames
string inFilename = "";
string outFilename = "";
// For file I/O
ifstream fin; //input file stream
ofstream fout; //output file stream
//User input of file name
cout%26lt;%26lt;"Enter the name of the input file: ";
getline(cin,inFilename);
//Works fine at this point, and opens the named file
//User input of file name
cout%26lt;%26lt;"Enter the new filename: ";
cin%26gt;%26gt;outFilename;
getline(cin,outFilename);
return 0;
}
When I compile I get no errors, but when I run the program, it will open the original file fine, but the output file won't pass the validity check, and won't even output the name of the file I had the user input in the error code as called for. What is the difference between the two!?!??!
C++ string help?
Actually, I don't see how that code is doing what you want. Try this;
std::string infilename;
std::string outfilename:
int main()
{
std::cout%26lt;%26lt;"please enter file to be opened"%26lt;%26lt;std::endl;
std::cin%26gt;%26gt;infilename;
fstream in(infilename.c_str(), ios::in);
if (in.good())
{
std::cout%26lt;%26lt;"file opening successful....."%26lt;%26lt;std::endl;
}
else if(in.bad())
{
std::cout%26lt;%26lt;" file opening failure....."%26lt;%26lt;std::endl;
return 0;
}
std::cout%26lt;%26lt;"please enter output filename"%26lt;%26lt;std::endl;
std::cin%26gt;%26gt;outfilename;
ofstream out(outfilename.c_str(), ios::out);
out%26lt;%26lt;"hi, I'm writing to this file!"%26lt;%26lt;std::endl;
in.close();
out.close();
return 0;
}
C++ string editing?
ok using
#inlcude %26lt;iostream%26gt;
and
#include %26lt;cstring%26gt;
im wanting to make a program that takes a string you enter and replaces certain characters int he string with spesific other characters
like an ecryptor, but not for that perpous
now i got so far as to have the user enter the string with cin.getline
but i dont know how to have the program read the string and act on it
p.s. im willing to go throgh a tedious proccess of listing the characters and there replacements so all i need to know is how to read the string, and replace spesific characters with other spesific characters
ok?
ok.
=]
C++ string editing?
Code to iterate thru the string and replace all the
character a with character b
string::iterator It = str.begin();
while ( It != str.end() )
{
if ( *It == ' a' )
*It = 'b';
}
cout%26lt;%26lt;str
Hope this help
Reply:Using character strings (declared like you have, such as char str[N]; or char* str;) makes dipping into the string to deal with individual characters easy, because your string is really an array. So the first letter is at str[0], the second is str[1], and so on. So let's say I wanted to search through my string and replace the letter a with the letter B (and capitalization does matter!). I would write:
int i = 0, n = 5000;
char str[5000];
.
.
Read in string
.
.
while (i %26lt; n) {
if ( str[i] == 'a' ) str[i] = 'B'; //Note that I used single quotes
i++; //i = i+1;
}
So if my string was "Apple's are very great!" to start with, it would end up being "Apple's Bre very greBt!".
kudzu
#inlcude %26lt;iostream%26gt;
and
#include %26lt;cstring%26gt;
im wanting to make a program that takes a string you enter and replaces certain characters int he string with spesific other characters
like an ecryptor, but not for that perpous
now i got so far as to have the user enter the string with cin.getline
but i dont know how to have the program read the string and act on it
p.s. im willing to go throgh a tedious proccess of listing the characters and there replacements so all i need to know is how to read the string, and replace spesific characters with other spesific characters
ok?
ok.
=]
C++ string editing?
Code to iterate thru the string and replace all the
character a with character b
string::iterator It = str.begin();
while ( It != str.end() )
{
if ( *It == ' a' )
*It = 'b';
}
cout%26lt;%26lt;str
Hope this help
Reply:Using character strings (declared like you have, such as char str[N]; or char* str;) makes dipping into the string to deal with individual characters easy, because your string is really an array. So the first letter is at str[0], the second is str[1], and so on. So let's say I wanted to search through my string and replace the letter a with the letter B (and capitalization does matter!). I would write:
int i = 0, n = 5000;
char str[5000];
.
.
Read in string
.
.
while (i %26lt; n) {
if ( str[i] == 'a' ) str[i] = 'B'; //Note that I used single quotes
i++; //i = i+1;
}
So if my string was "Apple's are very great!" to start with, it would end up being "Apple's Bre very greBt!".
kudzu
C++ string functions help?
I need to write a library similar to the %26lt;string.h%26gt; header file. I need help writing the following functions. They are included in my own class called "string".
void resize(unsigned int, char);
//resizes character array "Buffer" to number specified by
//first parameter
//fills extra space by the second parameter character
void insert(unsigned int, string %26amp;);
//Inserts a string into "Buffer" a character array.
//First parameter: Place to insert
//Second parameter: string to insert.
void remove(unsigned int, unsigned int);
//removes characters from "Buffer", a character array.
//First parameter : Starting position,
//Second parameter : number of characters to remove.
C++ string functions help?
Okay, this is pretty obviously homework. I won't show any code here, but I'll give you an idea how to implement the functions listed.
First, void resize(unsigned int, char); It has to do these things in approximately this order:
Validate int as greater than zero, or the operation is over before it starts. Next, it needs to allocate memory for a new Buffer with the extra space. Oh-oh. How do you find the buffer if it doesn't return a pointer or a reference to it? Better change the return type to char%26amp; or char *. Okay, now the new characters are written into the new buffer and then the old characters ... Oh-oh, we need to know where that things at too. Better include a reference or pointer to the old buffer as a parameter. So we take the old buffer and move the old characters over into the new buffer behind(?!) the new characters. Rats! Do we need to consider that the new characters should always be prepended or appended or does it change?
void insert(unsigned int, string %26amp; old_string, string %26amp; new_string); maybe?
void remove(unsigned int, unsigned int, string %26amp; buffer);
Unless you MUST follow these exact prototypes for your assignment, you may want to consider these modifications.
I think you can work these last two from the first walk through I gave you. They aren't really any different as to the mechanics of the problem, just what information is needed to operate from. Good luck!
Reply:I can understand that. Next time post partial code with specific questions and I (we?) can take the sting out of those sticky points. Sorry to be a drag. Cheers! Report It
Reply:Sounds like homework to me...
And if you can't do these simple things, you are in trouble!
Do it as a for(i=..;i%26lt;..;i++) loop, and use Buffer[i].
(or review the use of pointers: that's the beauty of C)
void resize(unsigned int, char);
//resizes character array "Buffer" to number specified by
//first parameter
//fills extra space by the second parameter character
void insert(unsigned int, string %26amp;);
//Inserts a string into "Buffer" a character array.
//First parameter: Place to insert
//Second parameter: string to insert.
void remove(unsigned int, unsigned int);
//removes characters from "Buffer", a character array.
//First parameter : Starting position,
//Second parameter : number of characters to remove.
C++ string functions help?
Okay, this is pretty obviously homework. I won't show any code here, but I'll give you an idea how to implement the functions listed.
First, void resize(unsigned int, char); It has to do these things in approximately this order:
Validate int as greater than zero, or the operation is over before it starts. Next, it needs to allocate memory for a new Buffer with the extra space. Oh-oh. How do you find the buffer if it doesn't return a pointer or a reference to it? Better change the return type to char%26amp; or char *. Okay, now the new characters are written into the new buffer and then the old characters ... Oh-oh, we need to know where that things at too. Better include a reference or pointer to the old buffer as a parameter. So we take the old buffer and move the old characters over into the new buffer behind(?!) the new characters. Rats! Do we need to consider that the new characters should always be prepended or appended or does it change?
void insert(unsigned int, string %26amp; old_string, string %26amp; new_string); maybe?
void remove(unsigned int, unsigned int, string %26amp; buffer);
Unless you MUST follow these exact prototypes for your assignment, you may want to consider these modifications.
I think you can work these last two from the first walk through I gave you. They aren't really any different as to the mechanics of the problem, just what information is needed to operate from. Good luck!
Reply:I can understand that. Next time post partial code with specific questions and I (we?) can take the sting out of those sticky points. Sorry to be a drag. Cheers! Report It
Reply:Sounds like homework to me...
And if you can't do these simple things, you are in trouble!
Do it as a for(i=..;i%26lt;..;i++) loop, and use Buffer[i].
(or review the use of pointers: that's the beauty of C)
Can someone please help me with a c++ program?
ok i have a program which is supposed to work but doesnt, it doesnt output any of the info that i need it to, all that it outputs is the following 20 times, increasing the number by 1 every time:
Record #0 from readdata:
from SetAll
not sure whats wrong with my code, must have something to do with reading in stuff from file, ill post the parts which probably contain the mistake
void SetAll(string l,string f,string s,string c,string st,string z,string M,string m,int i){
cout%26lt;%26lt;"from SetAll"%26lt;%26lt;l%26lt;%26lt;" "%26lt;%26lt;f%26lt;%26lt;" "%26lt;%26lt;s%26lt;%26lt;" "%26lt;%26lt;c%26lt;%26lt;" "%26lt;%26lt;st%26lt;%26lt;" "%26lt;%26lt;z%26lt;%26lt;" "%26lt;%26lt;M%26lt;%26lt;" "%26lt;%26lt;m%26lt;%26lt;endl;
last=l;first=f;street=s;city=c;state=st;...
}
void label(){
cout%26lt;%26lt;first%26lt;%26lt;" "%26lt;%26lt;last%26lt;%26lt;endl;
cout%26lt;%26lt;street%26lt;%26lt;endl;
cout%26lt;%26lt;city%26lt;%26lt;", "%26lt;%26lt;state%26lt;%26lt;" " %26lt;%26lt; zip %26lt;%26lt; endl %26lt;%26lt; endl;;
}
void print(){
Can someone please help me with a c++ program?
You need to use the debugger, or put cout statements at key places to help you debug. This is the life of a programmer.
Record #0 from readdata:
from SetAll
not sure whats wrong with my code, must have something to do with reading in stuff from file, ill post the parts which probably contain the mistake
void SetAll(string l,string f,string s,string c,string st,string z,string M,string m,int i){
cout%26lt;%26lt;"from SetAll"%26lt;%26lt;l%26lt;%26lt;" "%26lt;%26lt;f%26lt;%26lt;" "%26lt;%26lt;s%26lt;%26lt;" "%26lt;%26lt;c%26lt;%26lt;" "%26lt;%26lt;st%26lt;%26lt;" "%26lt;%26lt;z%26lt;%26lt;" "%26lt;%26lt;M%26lt;%26lt;" "%26lt;%26lt;m%26lt;%26lt;endl;
last=l;first=f;street=s;city=c;state=st;...
}
void label(){
cout%26lt;%26lt;first%26lt;%26lt;" "%26lt;%26lt;last%26lt;%26lt;endl;
cout%26lt;%26lt;street%26lt;%26lt;endl;
cout%26lt;%26lt;city%26lt;%26lt;", "%26lt;%26lt;state%26lt;%26lt;" " %26lt;%26lt; zip %26lt;%26lt; endl %26lt;%26lt; endl;;
}
void print(){
Can someone please help me with a c++ program?
You need to use the debugger, or put cout statements at key places to help you debug. This is the life of a programmer.
Subscribe to:
Posts (Atom)