Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,896 members, 7,814,030 topics. Date: Wednesday, 01 May 2024 at 02:02 AM

How To Run Console C/c++ Programs On Your Android Device - Phones - Nairaland

Nairaland Forum / Science/Technology / Phones / How To Run Console C/c++ Programs On Your Android Device (5158 Views)

How To Use PS2 Controller On Your Android Device / How To Unroot Your Android Device Using King Root / Is Your Android Phone Malfunctioning? Get Help Here (2) (3) (4)

(1) (Reply)

How To Run Console C/c++ Programs On Your Android Device by Nobody: 8:38am On May 06, 2015
Do you know that you can run c/c++ console application on your android device? If not, then this a thread for you.
what is a console app?
Console app is simply an application that you control with a keyboard input. It doesn't have any eye catching graphical user interface (gui).

whats the point of running an app that does nothing graphicaly interesting?
1. For educational purpose.

2. Easy to programme and execute.

3. Memory efficiency.

4. speed of execution ..etc


what do I need to begin?
1. A rooted android device. I am using gtn7100 (android 4.1.1), I haven' tried this on any other device so I can't assure you how this tutorial will behave on other android devices, but feel free to experiment.

2. X-plore file manager. you can download it from playstore or mobogenie. after you download and install it, open it, hit the menu key ●●-> configuration ●●-> root access ●●-> superuser + mount writeable.
***I advice you to set app password coz this app can do wonders in the hands of an inexperienced operator*****


3. busybox. this is optional but use full. also dowload via mobogenie or playstore. some utility programs for command line.


4.terminal emulator. download via mobogenie or playstore. for running your console app via command line.

5. cppDroid. download via mobogenie or playstore.
this is the app that you code and compile ur c/c++ program with. it comes with a built in code editor.

6. Hacker's keyboard. this app make is easy to type like you are using a full computer keyboard.


and you are good to go.


^^^configuration tutorials to be uploaded once I see interested followers^^^


**** ********
* ask me questions if u are stuck *
* *
Re: How To Run Console C/c++ Programs On Your Android Device by Nobody: 8:42am On May 06, 2015
this is a simple program that prints fibonacci sequence from '1 to n', where n is a number (interger) passed via command line.
for example to compute fibonacci 1 to 50, I simple type in my terminal emulator something like this::

fibmem 50 ** then ENTER KEY**

where fibmem is an app that a compiled with cppDroid, and moved it to system/bin with my X-plore file manager. and 50 tells the program to compute fibonacci 1 to 50. fibmem, the 'mem' stands memoized fibonacci which is magically fast I tell you.

/***your guestions highly welcomed***//

*#*#&##**#**#**#*#**#*#*#**#**#*#*#*#*#**#*#*#*


#include <stdio.h>
#include <stdlib.h>
double mem[1000] ; //memory fo precomputed fib
double fib( int n) ;
int main( int argc, char *argv[]){
if( argc == 2) {
int n = atoi(argv[1] ) ;
for( int i = 1; i <= n; ++i){
printf("fib( %d ) = %.0f\n", i, fib(i));
}
return argc; //dummy return value
}
else
printf("USAGE: %s int\n",argv[0] ) ;
}

//fib function

double fib( int n) {
double f;
if(mem[n] )
return mem[n];
if( n <= 2)
f = 1;
else
f = fib(n-1) + fib(n-2) ; //recursive call to fib()
mem[n] = f;
return f;
}




##screen shot included grin

4 Shares

Re: How To Run Console C/c++ Programs On Your Android Device by Nobody: 1:18pm On May 06, 2015
mods front page please!!!

I wannt share and learn from c experts.

(1) (Reply)

Top 5 Smartphones That Supports Three SIM Cards (2017) / TECNO Camon X Pro Vs Phantom 8 - Speed, Benchmarks and Ram Management Test / See MOTOROLA In A New Look. This Phone Beats Iphone 11 Pro (video)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.