MAIMONIDES w/ Daz, MC Eiht, RBX, Pharcyde, Spice 1, Dru Down, Crooked I, Kool G Rap, Project Pat, Bone Thugs, Cold 187um, Knoc-Turn'al, Boogie +
Home
Help
Login
Register
It's October 06, 2025, 04:06:23 PM
Welcome,
Guest
. Please
login
or
register
.
Login
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
West Coast Connection Forum
|
Lifestyle
|
Tha G-Spot
(Moderator:
Duck Duck Doggy
) |
c++ Help please anyone! Urgent~
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: c++ Help please anyone! Urgent~ (Read 187 times)
::Mr. Hahn::
Muthafuckin' Don!
Posts: 912
Karma: 24
c++ Help please anyone! Urgent~
«
on:
March 19, 2005, 06:44:15 PM »
Hey guys,
Anyone know much about structs or passing variables to const?
I need to pass a user defined string to a function to process the string..
However, the variable in the function is defined as a const, so i dont know what to do...
Please help me..
const int MAXLINES = 500; // Maximum number of lines of text
const string PUNCTUATION = ",.;
)"; // Punctuation characters
const string SPACE = " \t\n"; // Space characters
struct Text
{
string lines[MAXLINES]; // Text lines
int lastLine; // Index of the last line with text.
// If there is no text, lastline < 0
};
void tokenise (const Text &text,
int &countPunctuation,
int &countWords, int &countOther,
Text &tokens)
{
}
The string entered by the user in the main function has to go to:
"const Text &text"
However, when i go
cin >> text;
It doesnt work..
Idea's?
Logged
Da WCC Hopar!
Muthafuckin' Don!
Posts: 1540
Karma: 159
I love to see her walk off!
Re: c++ Help please anyone! Urgent~
«
Reply #1 on:
March 19, 2005, 07:20:26 PM »
i dont have single clue on wat u just said ive worked wit c++ before and neva go to far on it
Logged
::Mr. Hahn::
Muthafuckin' Don!
Posts: 912
Karma: 24
Re: c++ Help please anyone! Urgent~
«
Reply #2 on:
March 19, 2005, 07:32:24 PM »
its cool, thx for like..replying though!~
Logged
Suga Foot
Hennessy Chaser
Muthafuckin' Don!
Posts: 10783
Thanked: 56 times
Karma: 587
Re: c++ Help please anyone! Urgent~
«
Reply #3 on:
March 20, 2005, 01:21:32 AM »
Logged
Don Seer
Connected
Muthafuckin' Don!
Posts: 23398
Thanked: 15 times
Karma: 1037
Re: c++ Help please anyone! Urgent~
«
Reply #4 on:
March 20, 2005, 01:43:39 AM »
uh dude...
const means dont touch....
remove the const from your parameter being passed in..
btw.. i've been coding c++ for over 10 years now.. i've been at my current job doing it since mid '96.. and could prog in it for a few years before that..
also.. what are thsoe & things for?
if you mean to modify the variables inside the function.. i'd do it like this...
typedef struct _tag_Text
{
string lines[MAXLINES]; // Text lines
int lastLine; // Index of the last line with text.
// If there is no text, lastline < 0
} MY_TEXT_TYPE, *PMY_TEXT_TYPE;
void tokenise (PMY_TEXT_TYPE pText,
int *pnCountPunctuation,
int *pnCountWords, int *pnCountOther,
PMY_TEXT_TYPE pTokens)
{
}
holla..
Logged
::Mr. Hahn::
Muthafuckin' Don!
Posts: 912
Karma: 24
Re: c++ Help please anyone! Urgent~
«
Reply #5 on:
March 20, 2005, 02:23:04 AM »
i wish it were that simple.
However, thats defined in the header file and we are not allowed to change that struct/function.
We must use it.
We are also not allowed to use pointers to get around the const...sigh...
I heard its got something to do with inputting it through the text.lines[] because its a string array and u use some sort of loop to enter in the data. Then pass it to tokenise..
How do i do that?
Logged
Don Seer
Connected
Muthafuckin' Don!
Posts: 23398
Thanked: 15 times
Karma: 1037
Re: c++ Help please anyone! Urgent~
«
Reply #6 on:
March 20, 2005, 11:18:40 AM »
silly question what is "it doesnt work?" doesnt build?
should it be
cin >> text.lines;
or
cin >> text->lines;
Logged
boycriedwolf619
Muthafuckin' Don!
Posts: 1758
Karma: 163
Re: c++ Help please anyone! Urgent~
«
Reply #7 on:
March 20, 2005, 06:16:16 PM »
h
Quote from: Overseer on March 20, 2005, 01:43:39 AM
also.. what are thsoe & things for?
that symbol means pass by reference
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
West Coast Connection Forum
|
Lifestyle
|
Tha G-Spot
(Moderator:
Duck Duck Doggy
) |
c++ Help please anyone! Urgent~
There was an error while thanking
Thanking...