rand() % (LETTERS+65) +65
as I found on a C++ reference web page, but that certainly gives me more stuff than only numbers in range 65-65+LETTERS!
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
Arnstein
Norway3381 Posts
rand() % (LETTERS+65) +65 as I found on a C++ reference web page, but that certainly gives me more stuff than only numbers in range 65-65+LETTERS! | ||
|
KaiserJohan
Sweden1808 Posts
Plus when you know one IDE, it's not THAT hard to get into others, and you know what to look for. | ||
|
Tobberoth
Sweden6375 Posts
On February 07 2013 06:58 ChrisXIV wrote: Show nested quote + On February 07 2013 06:46 Kambing wrote: On February 07 2013 06:20 ChrisXIV wrote: I want to start programming in C++, I already know Java. Now I need a (free) compiler that's good for beginners, I tried the Visual Studio one and that was just too much, I want something where I can just easily create a few classes, anything spring to mind? Make sure you distinguish compiler from IDE. On windows, your only real options for compilers are Microsoft's offering (Visual C++) or gcc via cygwin. What you probably mean is IDE in which case, no, there's no decent, non-complicated learning-level C++ IDE. If VS puts you off, then I recommend simply loading up a text editor and working off the command line as all the other IDEs out there approach similiar level of complexities. Other free windows IDEs for C++ include Eclipse CDT and Qt Creator. Ah yes, IDE, don't know why I keep forgetting that word. Hm, that sucks. It's just that clicking through all those options in VS with no idea what they do...oh well, text editor it is, thank you. I really recommend learning and using Visual Studio. Not only will it definitely be what you work with professionally in the future if you work with windows development, its intellisense is out of this world, once you get used to it, using any other IDE is a dread. Safe to say, Visual Studio is quite a big program to learn and might be daunting at first, but it's surprisingly easy to use once you're used to it and can be customized beyond belief as in what windows it shows etc. It's also ridiculously powerful once you get to know some of the features such as debugging etc. I'm pretty sure there are tutorials on how VS works and you would only need to know the most important options to start (starting a project, adding classes, building). Personally I only knew how to program Java and Python but was hired as a C# programmer. Learned C# is about a week and started using VS at work immediately. At first it was confusing, but I got used to it very quickly... with a decent manual or tutorial, you should be up and running in no-time. | ||
|
Abductedonut
United States324 Posts
On February 07 2013 17:06 Arnstein wrote: How can I get a random number between 65 and 65+LETTERS? Right now I use this: rand() % (LETTERS+65) +65 as I found on a C++ reference web page, but that certainly gives me more stuff than only numbers in range 65-65+LETTERS!
It's rand()%(LETTERS-65)+65 *edit* This is obviously assuming LETTERS > 65. Otherwise, you need absolute value. *edit* If you want to impress your teacher: rand()%( (LETTERS > 65) ? LETTERS-65 : 65-LETTERS) + 65 Be careful though, if LETTERS == 65 you're boned.. | ||
|
Arnstein
Norway3381 Posts
| ||
|
Abductedonut
United States324 Posts
On February 07 2013 17:42 Arnstein wrote: Letters is actually a CONST INT sat to 6. I am trying to make a function that makes a random char from a-f. So then I would have to get a random number from 65-71. (I am told to use the const though)
| ||
|
Arnstein
Norway3381 Posts
![]() Thanks a lot! | ||
|
MisterD
Germany1338 Posts
On February 07 2013 11:16 darkness wrote: I'm having a bit of trouble to understand C memory management. Could you please show me an easy to understand guide? What I also need is perhaps some practical examples where it's crucial to deal with memory instead of stack. Thanks ![]() there isn't actually much to it. system memory is separated into stack and heap like in most languages. your entire heap is essentially one giant array. Firstly, your compiled program lies somewhere in there. Secondly, you can reserve multiple ranges of slots in there (calling malloc(size) returns the memory address called pointer, which you can think of as the "index in the giant array" so to speak, where your reserved section starts) to store your stuff and once you don't need one anymore you give it back to the system (by calling free(pointer); ) so someone else can use it. Dereferencing a pointer essentially just means to access the value stored at the given index. In case of reading from an actual array that you allocated on the heap for example, you can go "the pointer (where the array starts) plus 3 lots further, read the value at this position". And then you don't pay attention, iterate one index too far, access a location that doesn't actually belong to you, and either the operating system detects it and shuts you down to prevent hacking or your program crashes because someone else put some numbers there that are not what your code is written to handle. It is the most precise you can get which benefits performance, on the other hand though it's incredibly tedious and annoying and extremely vulnerable for creating bugs. Stack works like any other programming language. as for what to put on heap and what on stack: If you reserve a block of memory that's only going to be used in the function you are currently in (and maybe some functions it calls, but it will not escape this scope), then it's fine to put it on the stack (as long as it's not HUGE). Advantage is you don't need to clean it up yourself, it disappears as soon as your method is done executing, and it doesn't interact with all the stuff on the heap. Disadvantage is, it will disappear as soon as your method is done executing. so, if you reserve an area to fill it with data, that will survive for longer than your method (say, load an image for later use), then you will need to put it on the heap by manually reserving space there and you will have to manually free the space again once you don't need it anymore. Note though that it is possible for the compiler to store some data in the heap although you wrote it in a way that looks like it would be on the stack. But that's transparent and you don't need to care about it at all, it won't interfere with your program. Trust your compiler magic! | ||
|
Mistakes
United States1102 Posts
+ Show Spoiler + alter table l_employees add constraint l_employees_hire check (hire_date > #01/01/1995#); I need to add a constraint that checks for employees that were hired after 1995, and this statement is giving me an error in MS Access for SQL. | ||
|
Shield
Bulgaria4824 Posts
![]() | ||
|
lilwisper
United States2515 Posts
On February 08 2013 06:34 Mistakes wrote: Hi all, I'm having some trouble with this SQL statement. It's probably something stupid easy that I'm just looking past but I'd love some advice. + Show Spoiler + alter table l_employees add constraint l_employees_hire check (hire_date > #01/01/1995#); I need to add a constraint that checks for employees that were hired after 1995, and this statement is giving me an error in MS Access for SQL. Taking a stab at it without being able to see the error code you got, I would say to double check your datatype in hire_date. I believe in Access that the Date datatype handles a bit differently than Text datatype when it comes to doing date comparisons. | ||
|
Mistakes
United States1102 Posts
| ||
|
nunez
Norway4003 Posts
just... one with legs... JUST legs and one eye. just guts lying around with some hair on it. single nails lying around... at least mine would be. i need to learn to debug, and not just try to comment out single lines and recompile until i "found the error". i need to learn to debug. | ||
|
Mistakes
United States1102 Posts
I'm trying to get an output of first names in whole and last names with just one letter, a period, and a space like so: "Skylar Hoy" in the database in a field called (full_name) to: "Skylar H. " This is the code that I have: + Show Spoiler + SELECT employee_id, first_name & ' ' & last_name as full_name FROM l_employees; Seems like anything else I try besides just returning the full name, last name in whole, gives me either an error or the wrong output. Suggestions? | ||
|
Craton
United States17274 Posts
SELECT employee_id, first_name & ' ' & LEFT(last_name, 1) & '.' FROM l_employees; Probably. | ||
|
Mistakes
United States1102 Posts
| ||
|
Mistakes
United States1102 Posts
On February 08 2013 14:37 Craton wrote: Something like SELECT employee_id, first_name & ' ' & LEFT(last_name, 1) & '.' FROM l_employees; Probably. That worked perfectly! Thank you very much. :D | ||
|
enigmaticcam
United States280 Posts
| ||
|
Shield
Bulgaria4824 Posts
I hope C++ surprises me more tho. ![]() Edit: Oh yeah, no built-in threads & classes feature. I've heard of pthread, but isn't this something that doesn't come as standard? | ||
|
CptCutter
United Kingdom370 Posts
On February 10 2013 00:11 darkness wrote: I'm currently learning C which I wanted to do eventually, but I gotta say Java is a much higher level language. I've realised this when I had to deal with getchar() and putchar(). Also Java's error detection is superior. I hope C++ surprises me more tho. ![]() Edit: Oh yeah, no built-in threads & classes feature. I've heard of pthread, but isn't this something that doesn't come as standard? I have not learnt any C, but im guessing its similar to programming c++ procedurally. anyways, you will find out that java is amazing for the error messages it gives, but is generally a pain in the ass due to other reasons. And then you will find out that C++ is generally better due to having strict control over pointers, but a pain in the ass when your linking goes screwy or you programmed a large piece of code, and spend hours trying to find the "trying to access wrong memory" error. I generally tend to prefer C++ even with its annoying error messages because it gives far more control over the programming. C# is nice too. | ||
| ||
StarCraft 2 StarCraft: Brood War Dota 2 Counter-Strike Heroes of the Storm Other Games Grubby4061 tarik_tv1892 RotterdaM186 C9.Mang0133 Trikslyr75 XaKoH Mew2King27 ViBE27 Chillindude21 Organizations
StarCraft 2 • musti20045 StarCraft: Brood War• Dystopia_ • IndyKCrew • sooper7s • AfreecaTV YouTube • Migwel • intothetv • LaughNgamezSOOP • Kozan Dota 2 League of Legends Other Games |
|
Replay Cast
Korean StarCraft League
CranKy Ducklings
WardiTV 2025
SC Evo League
BSL 21
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
WardiTV 2025
OSC
[ Show More ] BSL 21
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
Wardi Open
StarCraft2.fi
Monday Night Weeklies
Replay Cast
WardiTV 2025
StarCraft2.fi
PiGosaur Monday
StarCraft2.fi
Tenacious Turtle Tussle
The PondCast
WardiTV 2025
StarCraft2.fi
|
|
|