Thanks :)
Got code near working with STL, wont be shortest but i'll be happy as long as it works hehe :)
Printable View
Thanks :)
Got code near working with STL, wont be shortest but i'll be happy as long as it works hehe :)
No,not 100% correct.Quote:
Originally posted by -KEN-
Change your files from a .cpp extensiopn to a .c extension. Problem solved.
6.3.2.2.
The types char ** and const char ** are both pointers to unqualified types that are not the same type, they are not compatible types. Therefore, a call with an argument of type char** corresponding to a parameter of type const char ** is not allowed. Therefore, the constraint given in Section 6.3.2.2 is violated, and a diagnostic message must be produced.Quote:
Each argument shall have a type such that its value may be assigned to an object with the unqualified
version of the type of its corresponding parameter.
<from Expert C Programming - Peter van der Linden>
And what if it occurs more than once?Quote:
Originally posted by Prelude
For Everyone
That finds any occurance of 'word' in the table 'tab'. The function will return 0 if the word does not exist in the table and 1 if the word is found. The two-dimensional indices of the word will be placed in the array 'indices'.
[edit]
Furthermore, what assumptions are we given? Are we using your example of the provided 'indicies' array, and 'tab'? Or are we to assume there is an arbitrary length of either?
If the latter, your problem is unsolvable. The reason being, unless you have a way to specificly tell us we are at the end of the 'tab' array, we will never know where the end is.
One could try and assume, assuming that every element in 'indicies' has been preset to -1. However, if that isn't a given either, then again, your problem is not solvable.
You haven't defined the problem well enough.
[/edit]
Quzah.
I made my program so that if there are more than 1 word, only the first one found is stored. Since she hasn't defined any behaviour for more than 1 occurance of the word, I take it that 1 word is all we're going to find.Quote:
And what if it occurs more than once?
The length of Indices have to be at least as large as the length of the word * 2, or you're unable to store the result. I guess that can be assumed. As for the size of Tab she mentioned that a quadratic form can be assumed (page 2), but it isn't hard to get the real dimensions manually (notice the empty string at the end?).Quote:
Are we using your example of the provided 'indicies' array, and 'tab'? Or are we to assume there is an arbitrary length of either?
You can tell this. There are methods for calculating the length of a string, and to find an empty string ( "" ) in an array of strings.Quote:
unless you have a way to specificly tell us we are at the end of the 'tab' array, we will never know where the end is.
I assumed this.Quote:
One could try and assume, assuming that every element in 'indicies' has been preset to -1
No you can't. What I was talking about is this:Quote:
Originally posted by Magos
You can tell this. There are methods for calculating the length of a string, and to find an empty string ( "" ) in an array of strings.
There is no way to know how many strings are in this array. This holds true for the number of indices also. Unless you set them all to -1 before the function call, you cannot know how many there are with the function prototype given us.Code:char *foo[] =
{
"you",
"cannot",
"tell",
"how",
"many",
"of",
"these",
"there",
"are",
"if",
"I",
"do",
"not",
"provide",
"an",
"empty",
"string",
"at",
"the",
"end"
};
Quzah.
>There is no way to know how many strings are in this array.
In that array, yes. In my array there's an empty string as the last element that you can use to determine where to stop.
>This holds true for the number of indices also.
You can assume that the array is at least large enough to hold all of the necessary values and a terminating -1.