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
  • No one is chatting at the moment.
    I @ idonthave: :)