Homebrew ARM 11 crash while using rand() command and trying to print()...

DeJay_Incognito

Member
OP
Newcomer
Joined
Oct 16, 2017
Messages
13
Trophies
0
Age
27
XP
72
Country
United States
Am I doing something wrong?:
Code:
            printf("\x1b[16;01H");
            int main(){
                srand(time(NULL));

                int x;
                x = rand() % 400;
                printf(x);
            };
        }
and the includes are:
#include <3ds.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
 

zoogie

playing around in the end of life
Developer
Joined
Nov 30, 2014
Messages
8,560
Trophies
2
XP
15,000
Country
Micronesia, Federated States of
Trying it now!

--------------------- MERGED ---------------------------


I am pretty sure it runs the variable and gets the number but nothing is printed... but no more ARM11 crash
The program is exiting without having time to display your message. Computers move really fast, you see.
https://github.com/devkitPro/3ds-examples/blob/master/templates/application/source/main.c#L11

Copypaste that while(appmainloop){stuff} loop under your code.
That while(Appmainloop) etc. will allow you to see the result of your code.
(sorry for all the edits, got stuff going on right now and I'm scatterbrained because of it lol)
 
Last edited by zoogie,

DeJay_Incognito

Member
OP
Newcomer
Joined
Oct 16, 2017
Messages
13
Trophies
0
Age
27
XP
72
Country
United States
The code you posted almost works.
Remove line 152, "x" is declared in a different function, so you can't use it outside of that function.
On line 152, add main(); so you can call the function you just declared. The reason nothing was printed was because you didn't do this.

Also, you're declaring a nested function called "main" within a function called "main", which is probably not what you want to do.
Um like this......
Code:
            int main(){
                srand(time(NULL));

                int x;
                x = rand() % 400;
                printf("\x1b[16;01H");
                printf("%d",x);
            };
            main()
        }
 

DeJay_Incognito

Member
OP
Newcomer
Joined
Oct 16, 2017
Messages
13
Trophies
0
Age
27
XP
72
Country
United States
Um like this......
Code:
            int main(){
                srand(time(NULL));

                int x;
                x = rand() % 400;
                printf("\x1b[16;01H");
                printf("%d",x);
            };
            main()
        }
Fixed i inserted printf("%d",main()); on line 152... but why is it giving me numbers larger than 400 -_- probably put it in wrong... but I must really thank you again... you guys were a big help... I will mention you in my program...
 
  • Like
Reactions: BL4Z3D247

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • realtimesave @ realtimesave:
    @SylverReZ that guy seriously spent over 2 grand on that hot wheels pc?
    +1
  • RedColoredStars @ RedColoredStars:
    LTT is a noob
  • RedColoredStars @ RedColoredStars:
    Guy doesnt know wtf hes talking about half the time
  • realtimesave @ realtimesave:
    @SylverReZ that reminds me that my friend sells CRTs he gets cheap or free for hundreds of dollars. people are dumb
    +1
  • RedColoredStars @ RedColoredStars:
    And is incredibly annoying.
  • realtimesave @ realtimesave:
    man I just washed my shoes and they look exactly the same as before I washed them :|
  • realtimesave @ realtimesave:
    luckily they didn't fall apart
  • RedColoredStars @ RedColoredStars:
    Some CRTs are very much worth the price
  • RedColoredStars @ RedColoredStars:
    i used to go out to the recycling center every couple weeks and look at the crts and other electronics people would drop off. Usually screens were broken or severely scratched from being tossed around. Did find a good one here and there, but never anything like a 1080i widescreen crt.
  • RedColoredStars @ RedColoredStars:
    Or a good contition 40" Sony Trini that weighs 300 lbs. lol
  • RedColoredStars @ RedColoredStars:
    Literally 300 lbs. lolol
  • BigOnYa @ BigOnYa:
    I have a few of those boat anchors in my basement I tried giving away but no one wanted them, So anyone close to Columbus, Ohio area that wants them, (26", 2x 19") please come get, for free.
  • RedColoredStars @ RedColoredStars:
    Dont know anyone wants those smaller ones. Most are after larger sizes and the kinda top of the line models
  • RedColoredStars @ RedColoredStars:
    Motion handling and input lag on those things destroy plasmas, led, oled
  • realtimesave @ realtimesave:
    I had some really nice CRTs I should've kept
  • realtimesave @ realtimesave:
    now I have all lcd
  • realtimesave @ realtimesave:
    one in particular I regret getting rid of oh well :|
  • realtimesave @ realtimesave:
    the Sonys and stuff I don't care about
  • realtimesave @ realtimesave:
    and used LCD are hard to sell I can imagine.. not worth much
  • realtimesave @ realtimesave:
    @SylverReZ where do u lurk
  • a_username_that_isnt_cool @ a_username_that_isnt_cool:
    Is it piracy if it was released for free? Not in my opinion, but I also think it's not piracy if buying it isn't owning it, and it's not piracy if you can't buy it from the original creators anymore.
  • K3Nv2 @ K3Nv2:
    Free release can have loopholes where they still make money through ads
    Xdqwerty @ Xdqwerty: :sad: