Jump to content

PruritusAni

Folding Member
  • Posts

    258
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by PruritusAni

  1. a C++ string is used via #include <string> and is way simpler, you don't have to worry about buffer overflow or strcmp, as you can use its operators == and != . They're basically dynamically allocated arrays of chars, so you don't have to specify lengths to start with, which simplifies things a lot. I suggest you use them as often as you can instead of the c-style strings (arrays of chars with fixed size is all they are, and their functionality is lacking at best). What you were using are c-style strings and the code I gave you is not very safe as it allows for buffer overflow. It's only a temporary solution until someone who knows how to deal with these p00py strings pops by and enlightens us. It's really not that crazy, as you'll program in C++ more you'll become very used to what I was doing over there, and once you get to write your own classes you'll see indeed just how powerful C++ can be.
  2. Ugh, I almost forgot my hatred for c-style strings. If you have a choice, always use regular strings as they're a lot more intuitive, and you don't have to worry about buffer overflows and reading the string in properly. I got this to work in my Visual Studio: #include <iostream> #include <cstring> #include <cstdio> using namespace std; struct Students { int ID; char name[80]; double GPA; char email [1000]; }; int main() { char choice[256]; // for yes or no Students nour = { 9103614, "Nour Eldin Ali", 3.81, "[email protected]" }; Students adham = { 9103615,"Adham Ayman Zaki", 3.91, "[email protected]" }; long ID; while(true) { cout << "Enter the student's ID " << endl; cin >> ID; if ( ID == 9103614 ) cout << endl << nour.name << endl << nour.GPA << endl << nour.email << endl << endl; else if ( ID == 9103615 ) cout << endl << adham.name << endl << adham.GPA << endl << nour.email << endl << endl; else cout << endl << "Incorrect ID" << endl << endl; cout << "if you want to do it again , type yes or no " << endl; cin >> choice; if ( !strcmp(choice, "yes") ) cout << endl << "Lets do it again!" << endl; else if ( !strcmp(choice, "no") ) break; else { cout << endl << "invalid choice, program terminates now" << endl; return 0; } } return 0; } it turns out that gets, or cin.getline(choice, 10) both fail so cin was the only way to make it work. It is very important to note however that if the guy enters smth with more than 9 characters you'll get buffer overflow and are setting your program up for easy hijacking. I made the string large enough that hopefully someone would get bored typing that many characters in, but this won't deter any buffer overflow attacks. Bottom line? don't use c-style strings. I know there must be a way to make this work with c-style strings, but I just don't know it. Surely there must be some c-style string expert lurking around here laughing at my incompetence.
  3. hmm weird, it never says "it worked"?I think it may have to do with some sort of basic assumption I'm making about c style strings and strings. let's try using strcmp after all. Try to see if this works: if ( strcmp(choice, "yes") == 0 ) cout<<"it worked"; else if ( strcmp(choice, "no") == 0) break; else { cout << "invalid choice, program terminates now" << endl; return 0; } I was told a long time ago, and many times after that by various programming profs to not use goto if I could avoid it at all, and I guess I obeyed. I think there are more elegant ways to do the same things a goto does, especially in objected oriented languages. You could easily use functions and classes along with the trusty while loop to circumvent any sort of goto usage. Some of the modern programming languages go so far as to lack a goto instruction (I know java and python don't have it), so I guess there may be some sort of goto shunning conspiracy that I'm also part of.
  4. It is not really that advanced what I did, just built a bit on top of what you were doing. Feel free to remove things from my code if they're too "fancy". Have you tried playing with my code a bit to see if it works? It should do more or less what you want your code to do. If you're using a for loop with no counter or stopping condition what you really want is the while loop. I personally don't care for using goto at all, so I avoid it, as it's easy to mess up things with it. Hope you get it to work properly.
  5. are there no == or != operators in the cstring class? Are you asking if the choice is not "yes"? There's a ! in there which negates the return value of strcmp in both conditional statments. perhaps avoiding goto like you would the plague is a good idea after all. Try it with a while loop and a break if the guy says no: int main () { // declare your needed variables and stuff here // brute force the two students here // perhaps expansions of the program would allow for adding of other students and storing them in a data structure while( true ) { cout << " Enter the student's number" << endl; cin >> ID; if (ID == smth) { //display that guy's stuff } else if (ID == smth else) { //display this other guy's stuff } else cout << "student with " << ID << " not found" << endl; cout << " Would you like to do this again?" << endl; cin >> choice; if (choice == "no" || choice == "No" || choice == "N") break; else if ( choice != "yes" || choice != "Yes" || choice != "Y") { cout << "invalid choice, program terminates now" << endl; return 0; } } return 0; }
  6. Try HWMonitor. It works fairly well at monitoring all sorts of temps, and some voltages.
  7. now that is class! You are to be commended on your efforts, and cooling prowess.
  8. the d14 is easily better. you may also want to look into a prolimatech megahalems, as it's also an awesome cooler. Couple it with some quality fans and you've got yourself a monster cooling solution.
  9. didn't it say that one of them (flourish) was used for directx diagnostics? Maybe the others the result of awesome procrastination on the part of a very musically inclined programmer. Or we could get crazy with the theories right here and claim they hold carefully encrypted code for when the global network of Windows becomes self aware. *grabs tinfoil hat* Nevertheless, it is indeed an awesome find, and I commend you for it, as I too love a good midi.
  10. there's two other midi files in there on my laptop (running XP): flourish and town but they're not nearly as good. what do these get used for anyways?
  11. I think it got us ... So if other folders do indeed see the little box (need to eliminate the possibility of me just being weird, as is often the case), a good way to get rid of line is to sacrifice the stars, and get the ribbon.
  12. But I am neither a donor nor staff, and yet I see that little thing ... weird.
  13. Odd. Maybe regular members just don't get one of those boxes? I don't remember it being there before the update, but my memory is not reliable unless smells or numbers are involved. You both seem to be folding, maybe joining the Folding members group will give you access to the box? Not to mention you get a fancy DNA strand to go with it (You lose the stars though). Can anyone confirm my speculations?
  14. do you actually need both 8pinners connected? I seem to recall a lot of similar high end boards needing the extra 8pin connection only for ridiculous overclocks. It should work just fine for a regular overclock with just one 8pin guy in there. EDIT: You might also want to take a look at this thread. There may be a way for you to get a second 8 pin cable.
  15. on the bottom left of the message when you edit it. It's a check box that says Show 'Edit by' line
  16. I thought that was optional, if you don't like it you can just not check the "show edited by" thing. Or do you want it to show as a way to timestamp edits, but would like it to be smaller? EDIT: I just edited it and checked the box, to annoy you.
  17. I do enjoy all of the listed options, but most of the time it's nearly therapeutic to go on a slaughtering spree without the legal ramifications. It's also a good way to completely reset the mind after prolonged abuse via complicated and attention demanding tasks. There's only so many hours one can spend focused on a certain task, so when a lot of these hours have to be logged in a few days, small breaks for FPS can work wonders.
  18. Woo! I won me some post apocalyptic Russian madness! I'm very excited as I hear it's a fantastic game. Congratulations to the other winners as well, especially to wevsspot. Many thanks go out to Bosco and MSI for putting this contest together.
  19. I just gave it a shot, but it still doesn't work on hulu, as one can see here. EDIT: and it also breaks adultswimfix just as bad as ad block plus. They ought to include a subscription filter to abp just for video streaming websites.
  20. The hulu ads aren't the worst out there, as the ones I've seen are only up to 5 seconds long. Sometimes ad block plus blocks the longer ones on other websites, but other times it just breaks the player in the process. Let us know if you figure out a better ad removal avenue.
  21. I would not go for the TX3 as I once had the misfortune of trying to spread it. It's the same viscosity as play-doh and only a method borne of frustration gave results. I am currently using Arctic MX3 and it works great. Non conductive, no curing time, and a breeze to work with. Paired with a lapped CPU (and that means I use even less of it) it has yielded fantastic results.
  22. More like stupidity is really cruel some times. Who the hell shoots a freaking AK at a wedding? It is also a worse than usual stupidity scenario when one takes into account the fact that weddings are such high alcohol intake events ...
  23. 8Gb and it's been coming in handy. Is it just me or do some of the people voting in this poll seem confused by the greater than symbols? I mean >8-9 means anything above 8 (not included) and not greater than 9 (included) , but who seriously has 8.5Gb or even 9Gb going on?
  24. I tried putting it in the signature, and it didn't work, I may have been slightly retarded in the process ... let me see if I can replicate the issue EDIT: There it is! My signature now has a broken HTML folding image going on under the working BB code one. EDIT2: I re-read your post, and realize why the HTML alternative isn't working .... It's because it is meant to be used on a website or blog .... So I was doing something retarded in the process all along.
×
×
  • Create New...