and I would like you to answer with a code or function which would work on that compiler...
Of course you would. That way you get us to do your work for you. Maybe you should read the Member Rules.
and I would like you to answer with a code or function which would work on that compiler...
Of course you would. That way you get us to do your work for you. Maybe you should read the Member Rules.
Rather than trying to describe it, which you are doing poorly, show us!
Post a small example of the file (3-4 lines) and exactly what you want printed.
Come to think of it, all you've done is continue trying to describe things. But it also sounds like you know what to do. If you've got it, say "thanks". If not, ask specific questions about what you don't understand.
Didn't the C++ Books thread mention any?
It makes no sense. We need more technical information you are attempting to use, like C++ strings or C-strings, other constraints you have.
please remember that i would love this to be if statment friendly, as im useing while and Do while Loops for this procidure
What does this mean? It makes no sense.
What is if statement friendly?
What do while and do loops have to do with ifstatments?
and would like to have all ifstatments catagorized the way i do lots of ifstatments, put them in Voids.
What do Voids have to do with anything?
Why/How do you categorize if statements then put them in Voids?
How do you put "ifstatements" in Voids
Is any of this actually germaine to the question? Is it more than simply finding a sequence of characters and printing everything after it?
Probably. Compile as a C program and fix the errors. That's the simplest technique.
Search for the string.
Add the length of the string to the location found
Start printing.
If you want a better description, give us more information about your situation.
I looked up the bubble sort and it's basically the same thing that I have in my program.
Really? I see 1 while
and 1 for
in your program. The program you linked to uses 2 for
statements.
I tested your sort with a 'real' bubble sort and came up with this:
Given an array in sorted order the number of compares for:
yours: 19 -- real: 19 (minimum)
Given an array in reverse order the number of compares for:
yours: 380 -- real: 190 (maximum)
Given an array in random order the number of compares for:
yours: 247 -- real: 169
You are using Turbo C++. You must quickly switch to standard Compilers, which are available freely in the internet.
Won't he fail the class by not using the compiler the instructor insists on?
And could you tell him what compiler other than Borland could possibly compile the posted code?
The number of compares in a real bubble sort is the Summation of N, N=0 to n-1. What is 1+2+3...+19?
Yours on the other hand is (20*20)-1 I believe.
So you might want to loop up how a real buble sort is defined and correct yours.
Care to give us specifics about the problem?
With the explanation you gave, the best answer is "then you did something wrong".
Then your file is not where the program can find it.
You are not testing for errors. If the program can't find the file, you ignore the error and read it anyway. Look up the file methods again and add error conditions with worthwhile messages.
Ok here it is...made the necesseray adjustments. Still Not Correct :|
you really need to explain what happens when asking for help. Based on this statement we can't tell if
1) you now have compile errors
2) you now have link errors
3) your program crashes
4) it surprisingly prints the words to "Jana Gana Mana"
Every post needs to be explicit. Detail what the problem is, and where you think the error is.
It's using the below but you need to include <string.h>, on dev c++ just <string> doesn't seem to work.
That's because string
is the header for the C++ string class. string.h
(or more correctly in C++ cstring
) is for c-strings.
Traditions can change. It's a requirement... ;o)
Output values to see what is happening while the program runs. This can also pinpoint where the error is and what variables have bad values.
Possibilities:
1) Change the message color to RED to make it more visible. If you can, change the background of the message to YELLOW to make it pop visually.
2) Add a button that must be pressed to get to the message box to override. Maybe add the hated "are you sure" button.
3A) Take into account the First Post date, not the Last Post date. Yes, a potential problem for a thread that actually does last for 3 months. So instead:
3B) If the message is displayed once, set an internal flag that marks the thread as ancient so the message always gets displayed.
Mix and match...
Only happened once for me.
OK, this is getting really annoying!
I spent 7 minutes trying to add a reply earlier and this CODE Detection would not let me add the post. It detected code. The post in the preview looked exactly the way I wanted it. But the code detection would not let me continue. If code is erroneously detected, we have to fix the post but there's no indication what needs to be corrected.
We need either
A) an indication of the problem (like from a compiler)
B) an override that lets the post get posted. This override could be a 'hidden' feature that those in the know are privy to (like a lot of the advanced editing features) so noobs can't override tagless code.
I thought I could say node1->left = &node2; // left = the address of node 2.
Is that right?
What happened when you tried it? Didn't it work?
And what The Dragon said is true. Make a pointer named head
that will point to the first node. That way if the first node has to change it's easy to add a node and relink to the new first node
And atlast there is no ending brace after return 0 (line 68) and no ' ; 'after return 0.
Proper formatting would have shown you this error in seconds.
What's Bruciweb?
Bruce was also thought of as a gay name... I think that's why in the Hulk TV show he was David Banner rather than Bruce Banner. Late 1970's version of political correctness.
from where you got that link ?
What he said! :o)
And secondly, You are nice, I was wrong when i said rude to you.
See? I grow on you after a while. Like fungus...
thirdly, Can i post my own written code for his/her help on this topic?
Let's try some logic here:
A) What grade will you get for doing his homework for him?
B) What grade does he deserve for you doing his homework for him?
Therefore:
C) [type your answer here :o]
WaltP's remark 2) isn't true.
Yes it is.
Because a very simple checksum formula is used (just add up the values) different pictures with the same values in it will produce the same checksum.
If different pictures have all the same values, it's the same picture. Can you provide any bitmaps that are different pictures but have the same values inside? I'd really like to see this. Now, if you're complaining about the fact that addition is commutative, so what?
There is an inherent problem with checksums to begin with. There are only so many checksums available based on storage size of the checksum.
Let's take a simple example. You have a checksum that's one byte. There are at most 256 different checksum values. So, if you have 257 pictures, at least 2 of them will have the same checksum.
When you use a 32 byte word, 4,294,967,296 different checksums are possible. Less of a chance for a small sample of pix (but possible). But with 4,294,967,297 pix at least 2 will have the same checksum.
The above is true for any simple checksum and any cryptographic hash function.
It used to be a connotation that it was a gay colour (Lesbian?)
It's also a connotation of Royalty. Guess which was first :)
I thought lavender was gay. Good thing this isn't BruciWeb... ;)
1) You didn't say that. How are we supposed to know you wanted to use 1990's technology.
2) Why can't it be run on Borland?
Refine the search.
I don't understand. The checksum lets you know if the pix are identical.
1) Identical pix have the same checksum.
2) Different pix have different checksums.
3) Different alpha values produce different pix, therefore different checksums.
4) Same alpha values on different pix do not produce same checksum (pix are different)
So I don't understand the problem at all. Unless it that the same visual pictures have different bitmaps because they are in fact different (larger, darker, watermark, etc). You can't use a checksum to test identical pictures that are internally different.
Pass the array to a function, and its length of course.
pseudo func code:
unsigned returnval = 9999999999999; // or the highest value you expect
for(unsigned i = 0; i < len; i++){
if(array element i is greater than returnval){
continue the loop
}
else make returnval equal to array element i
}
return returnval
.
Close. How about:
returnval = fist value in the array
for(unsigned i = 1; i < len; i++)
{
if(array element i is greater than returnval)
{
continue the loop
}
else make returnval equal to array element i
}
return returnval
But then again, you forgot to "return the index of the smallest element in the array". ;o)
I would have to politely disagree with phorce. Bubblesort would change the indexes of the elements which would prevent you from returning the index of the smallest value (a requirement).
Not if you do it correctly. But that's probably beyond the OP scope of knowlwdge. But, sorting is definitely the wrong way to go. You don't sort just to find the min or max values of any list. You sort to put the values in an order.
If you want to do it with sorting algorithms, you can copy the original array into a new array. Then sort it and store the smallest element. Comparing it with original array would give you its index as required.
Why? Here's what you propose:
1) Loop to copy the entire array into another array
2) Start the bubble sort
2a) Loop to put the lowest value into place (not you now have the lowest value but ignore it that fact)
2b) Loop again to put the next lowest in place.
2c) repeat for all the values -1 in the array (19 times total for 20 values)
3) Loop yet again to compare the sorted last value with each value in the original array.
There is another way which Bob has pointed out. In a loop check for smallest element. This will not change array index.
And this one is:
1) Start by assuming the first value is the lowest and …
FYI, char cPass;
defines one character. There is no way you can cram "correct" into one character.
Member RulesDo read the forum description to ensure it is is relevant for your posting.
Members who break a rule will usually be warned, followed by a points-based infraction for subsequent offenses. When a member is given an infraction, they accrue points which remain on their record for a time period. 10 or more infraction points will result in an auto-ban from DaniWeb effective until the number of active points falls below 10.
Do you really want to start getting infractions? I suggest you reread all the member rules again.
What happens when you sit at your desk with the code, pencil, and paper and actually follow the program line by line? Writing the variable values as they change?
Since this has nothing to do with C it should be posted elsewhere. Like Geeks Lounge.
Finish A and B to output the SPACEs on each line. Then the solution is obvious.
Neither do we. It's your code.
For the function void Combine()
on 187:
-- how many parameters are specified?
-- are they all needed? If not, fix the definition. If so, fix the calls.
Read the errors carefully. They tell you exactly what the problem is. What would "too few arguments" in a function call mean?
Line 195 - I don't see anything wrong with that definition of combine()
line 336 looks fine too.
Sounds like you'll have to supply more detailed information so we have a complete understanding of the problem.
You have to somehow label the nodes:
1 Does it have 4 legs? initial (1st) question
21Y Does it purr? 2nd level Yes
31Y Cat 3rd level Yes
31N Dog 3rd level No
22Y Does it swim? 2nd level No
32Y fish 3rd level Yes
32N 3rd level No
Something along those lines. You'll have to think through the linkages a little more deeply than this.
at the void combine
437 lines and you can't be more specific than that?
also at the part void add which precisely at combine(temp,"")
Meaning what? and where?
If you notice there are line numbers in your post. They might be useful.
I guess theoretically. But in practice, it should compile fine.
After a test, I could not get a clean compile at all. But since it's undefined, I really don't care... ;o)
You aren't checking anything with result_maxlength. There are no tests what-so-ever in your code.
Sit down with pencil and paper and draw out the variables, contents, and their storage space.
Then follow your program line by line and fill in the values.
And don't forget the \0s
How much space has been reserved for char a[] = "Woozle";
?? In total?
So will it actually fit into char c[5];
?
How much space for char b[] = "Heffalump";
So will it actually fit into char c[5];
too?
So if you changed your code to say (++a)++, your code would work in C++, but not in C.
No it won't. Pre- and post- incrementing the same value is called undefined behavior, therefore the result may be different on different compilers. The result is ambiguous. See this
You can space the numbers properly by adding the width value:printf("\nTigers %3d %3d %3d ", t," ", tw," ", tp,"\n");
This prints all numbers with 3 chracters, SPACE filled.
Also, division can't be done accurately with integers. Make a test program to see what happens when dividing various integer values.
OK. That makes more sense. I thought you were having an aneurysm ;o)
int Num1Num2[1][1]={0};
What the heck is this? You set up a 2-dimensional single integer. Why? It's completely worthless.
fflush(stdin); //this does not work why?
It's not designed to work. See this.
cin.get(); //this does not work why?
That's because of cin.getline(input,5,'\0');
. You left stuff in the input buffer. Just use cin.getline(input);
But when I enter "45:45" I get 45,4. The last character is missing.
char input[5];
isn't large enough. When you read a length of 5, you get 4 characters and the terminating '\0'. Define it as input[10]
to be sure. On the other hand, why not just use a C++ string?
Also, your formatting needs work. See this, too.
Set up an array with the values 1-MAX (array[MAX], MAX being 60)
set up a loop with index 1 to 20
get random number from 0 to MAX-index
use that number as index into array to store the next number
loop from MAX-index to MAX-2 and shuffle all contents down 1 entry
With 10 pages of posts here on DaniWeb alone, I'm sure you can find the answer using SEARCH.