Jump to content

Redturtle098

Member
  • Posts

    74
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Redturtle098 reacted to wanderingfool2 in C: Need help with structs   
    Code with comments
    typedef struct book { char **chapters; char title; char author; char *origin; } book_type; static struct book_type target_book; //Should be static book_type target_book; //Or it could be static struct book target_book; //Since you used typedef book { ... } book_type; then book_type becomes name...not struct book_type typedef struct page { char paragraph; } page_type; static stuct page_type content; //static page_type content; should be the line see above for reasoning //------------ //Other code //------------ char *origin; origin = malloc(1000); target_book.origin = origin; char *list[100]; list[0] = origin; target_book.chapters = list; struct content *pages = (struct content *)(origin); //where origin is where the pages struct resides //Don't try casing with variable names. Cast with types. With that said casting doesn't make sense here anyways //You only cast when you are wanting to change types and when changing the types is necceasary and makes sense //Origin is a char* [effectively a string] //Converting to a struct like you have doesn't make sense, while it's still a struct with char it's extremely bad practice //The reason is you could easily add in additional items into the struct and then your casting makes even less sense //but with that said...if you really did want to do casting it would be //page_type *pages = (page_type*) origin; //Highly do not recommend converting a char* to a struct like this //This I think should throw an error as well. pages->content first doesn't exist in any struct //like assuming pages was meant to be page_type...then the only member is paragraph (which is a single char) //with that said, even if content were there. It would need to be const char* definition as well as "xyz" is a constant string pages->content = "xyz"; //prints to pages int i = 10; //Not sure what you are trying... pages was already defined...but maybe this is in a different function? //again it's like what I said above. struct page or page_type should be used...but no clue what you are trying to do //as casting origin+1 doesn't make sense in terms of using struct's struct content *pages = (struct content *)(origin+i); //this doesn't work  
  2. Like
    Redturtle098 reacted to Sauron in C: Need help with structs   
    I'm not sure what you're trying to accomplish to be honest, if you just want to write characters into the array why not do so directly?
     
    Anyway, sure, if you reassign the pointer to a valid region of memory it will allow you to interpret it however you wish.
    By the way, at this point I'm assuming pages->content is supposed to be pages->paragraph... in which case you're trying to fit a string inside a single char.
  3. Like
    Redturtle098 reacted to jaslion in Rate my planned setup :)   
    One thing you can do is to future proof it a bit more is get a 3400g instead of the 3200g and add in a cheap case fan for in the front. If you want a 27 inch screen do get at the least a 1440p one as otherwise it's just not nice to use. 24 inches is already pushing the 1080p resolution and 27 inch is just too large for a screen you are so close to.
     
    Also mind going used for maybe a gpu? Then you could do a ryzen 3100 + far better gpu option instead of that crazy expensive 3400g.
  4. Like
    Redturtle098 reacted to Mateyyy in Rate my planned setup :)   
    No problem!
     
    Yeah, I was going to point out what you could've done better with your build but thankfully @jaslion did that.
    The monitor I put in the list though is 24" as opposed to the 27" you picked. If you were set on 27" you might need to look for a different option, but at that size you'll definitely want to look for 1440p panels. The BL2420PT I picked I have actually used personally for a year and a half now and I've got to say that I've been really satisfied with it.
  5. Like
    Redturtle098 reacted to jaslion in Rate my planned setup :)   
    This whole build is sorry to be hard. Trash.
     
    Ryzen needs dual channel ram and that is only 1 stick so that won't work.
    The 3200g has a built in gpu and that built in card is just infinitely better than the gt 710.
    The board is super cheap and low end. It does support the cpu but at least get a Msi b450 max board.
    Psu is bad will work but very low qualtiy mwe white one.
    Bad case. No airflow.
    1080p for 27 inch is bad as it's just going to be super pixelated.
     
    For when is this build planned? What games?
     
    If now go with this (without getting any input yet from you):
     
    https://au.pcpartpicker.com/list/sXNTk6
    PCPartPicker Part List: https://au.pcpartpicker.com/list/sXNTk6
    CPU: AMD Ryzen 3 3200G 3.6 GHz Quad-Core Processor  ($164.00 @ Shopping Express)
    Motherboard: MSI B450M PRO-M2 MAX Micro ATX AM4 Motherboard  ($119.00 @ BudgetPC)
    Memory: Team T-FORCE VULCAN Z 8 GB (2 x 4 GB) DDR4-3000 CL16 Memory  ($65.00 @ BudgetPC)
    Storage: Western Digital Blue 500 GB M.2-2280 Solid State Drive  ($89.00 @ Shopping Express)
    Case: Silverstone PS16B MicroATX Mini Tower Case  ($57.00 @ Umart)
    Power Supply: Corsair CXM (2015) 450 W 80+ Bronze Certified Semi-modular ATX Power Supply  ($102.00 @ I-Tech)
    Total: $596.00
    Prices include shipping, taxes, and discounts when available
    Generated by PCPartPicker 2020-07-03 21:52 AEST+1000
     
  6. Like
    Redturtle098 reacted to Mateyyy in Rate my planned setup :)   
    PCPartPicker Part List: https://au.pcpartpicker.com/list/MLKbPn
     
    CPU: AMD Ryzen 5 3400G 3.7 GHz Quad-Core Processor  ($259.00 @ Centre Com) 
    Motherboard: MSI B450M PRO-VDH MAX Micro ATX AM4 Motherboard  ($130.90 @ Device Deal) 
    Memory: Corsair Vengeance LPX 16 GB (2 x 8 GB) DDR4-3600 CL18 Memory  ($112.82 @ Amazon Australia) 
    Storage: Western Digital SN750 500 GB M.2-2280 NVME Solid State Drive  ($128.94 @ Amazon Australia) 
    Case: Phanteks Eclipse P300A Mesh ATX Mid Tower Case  ($99.00 @ PCCaseGear) 
    Power Supply: Corsair CV 450 W 80+ Bronze Certified ATX Power Supply  ($70.80 @ Device Deal) 
    Monitor: BenQ BL2420PT 23.8" 2560x1440 60 Hz Monitor  ($280.00 @ Device Deal) 

    Total: $1081.46
     
    ^ I'd recommend something along these lines, it'd be quite a good bit better overall.
  7. Like
    Redturtle098 reacted to mathijs727 in How to pass and return arrays in c?   
    In C, you could just pass a pointer to the start of the array + a number representing the size of the array.
    In C++ you can store the data in a std::array and pass a reference to that array.
    Adding to the array won’t be possible since it is fixed size (although you could add a dummy value when creating the array).
    In C++ you can also use a std::vector instead, which does support growing (and shrinking) dynamically.
     
    I don’t know about C, but sorting in C++ is easy:
    std::sort(std::begin(vector), std::end(vector));
  8. Like
    Redturtle098 reacted to colonel_mortis in How to pass and return arrays in c?   
    You can't pass arrays by value in C, but you can pass a pointer to the array.
    void sort(int* arr, int len) { // you can read and update arr[0]..arr[len-1] in here. // Simple bubblesort implementation: for (int end = len; end > 1; end--) { for (int i = 1; i < end; i++) { if (arr[i-1] > arr[i]) { int tmp = arr[i]; arr[i] = arr[i-1]; arr[i-1] = tmp; } } } } int main() { int nums[5] = {5, 8, 1, 3, 4}; sort(nums, 5); } You can play with this code here:

    (sorry, embedding repl.it is currently an admin-only feature, but I'm working on it).
  9. Agree
    Redturtle098 reacted to Brennan Price in Screen seizure   
    What are you using? Laptop? Desktop?... More information please. Either way it is likely to be display drivers having a fit. 
  10. Like
    Redturtle098 reacted to jincio in An interesting problem   
    i think this should work if i get your question
     
    Code:
  11. Informative
    Redturtle098 reacted to Dash Lambda in An interesting problem   
    I'm a little late, but this is my solution:
     
    What you're trying to find are compositions, where you represent a number as a sum of strictly positive integers. For an integer n, you can start with the composition consisting of n 1's and separate them with a choice of either a plus or a comma, and say a comma is 0 and a plus is 1. You get an n-1 bit binary number, and you just count up.
     
    For example:
     
    Input 3, get (1 _ 1 _ 1)
    00: (1, 1, 1)
    01: (1, 1 + 1) = (1, 2)
    10: (1 + 1, 1) = (2, 1)
    11: (1 + 1 + 1) = (3)
  12. Agree
    Redturtle098 reacted to vorticalbox in An interesting problem   
    Without using external tools I would take the input (3) make the highest number you can get for that input length (999)
     
    Then loop the range and add up each number (120 1+2+0) if that equals the input then push the result to a list.
     
    Any 1/2 length valid you can just append the 0. E.g 12 you would just make it 012.
     
     
  13. Agree
    Redturtle098 reacted to tikker in An interesting problem   
    Are we talking positive integers only? The brute force way would be to loop over numbers while subtracting and then constantly checking if you can reach 0 that way.
    You can cheat the first solution since you can always create that number by adding ones, so that's the easy one. If you consider a+b and b+a to be the same thing, this can limit the amount of numbers you need to search as well.
  14. Like
    Redturtle098 reacted to wasab in An interesting problem   
    Just brute force all the possible permutations.
  15. Like
    Redturtle098 reacted to KNG_HOLDY in An interesting problem   
    i dont know if this is what u wanted but w/e i was bored
     
    Code:
     
    Example input 3
    Example Input 5
     
     
    //Edit 
    this solution returns every possible perumtation 
    for example (0, 1) (1, 0) are both present in the result of input 1 even tho they are the same
  16. Like
    Redturtle098 reacted to PineyCreek in CPU fan turning on and off?   
    If you keep hearing the buzz though, monitor that.  If it gets worse...or if it suddenly stops and your system shuts down, you should probably open up the laptop and take steps.
  17. Like
    Redturtle098 reacted to TechyBen in CPU fan turning on and off?   
    Hopefully just dust then!
  18. Like
    Redturtle098 got a reaction from Ace McPlane in CPU fan turning on and off?   
    Not sure what happened, but it started working again!
    Thanks again for the help everyone!
  19. Like
    Redturtle098 reacted to Ace McPlane in CPU fan turning on and off?   
    Crap, my bad.
    I obviously mixed up the posts I was commenting on there, because I thought we were talking about a desktop
    Oops.
  20. Like
    Redturtle098 reacted to A Silver in CPU fan turning on and off?   
    A doubt an evo 212 would fit in a laptop...
  21. Like
    Redturtle098 reacted to Ace McPlane in CPU fan turning on and off?   
    Yea, or maybe something like an evo 212 or an h60.. whatever fits. Might last a bit longer than the crappy stock ones.
  22. Like
    Redturtle098 reacted to TechyBen in CPU fan turning on and off?   
    As above. Could be the thermal paste has worn out. Be careful, and check the model number, search online/youtube for tutorials if possible. As some laptops use thermal paste, some use thermal pads. Paste may not make contact in positions that have pads.
     
    Or dust in the fan. Or it's got rusty. Dust is easy to clean off. A broken/rusty fan needs the whole fan replacing.
     
    Sometimes it can be a driver problem. If you can post the full spec/model number, the manual/online support website will note any common faults.
  23. Like
    Redturtle098 reacted to A Silver in CPU fan turning on and off?   
    I would open it up and check if there is any dust or dirt build up which may restrict the fans movement. Also check if the fan spins freely and has little resistance when pushed by hand.
  24. Like
    Redturtle098 reacted to PineyCreek in CPU fan turning on and off?   
    If they're going to bother opening it up it may be worth ordering the replacement CPU fan spare part from the OEM.  Replacement fan shouldn't be that much.
  25. Like
    Redturtle098 reacted to Senzelian in CPU fan turning on and off?   
    I guess he will have to open it up.
    I'd clean the fan and reapply thermal paste to the CPU while at it. Maybe a bit of silicone oil could help that fan bearing. 
×