In Linux, everything is a file, so the Android system itself is just Linux+Java, and it also runs in the Linux environment. Usually, we use printf when debugging programs. In Android, we will use logcat. Now, I will introduce you to a commonly used debugging method, the debug writing file debugging method. In the Android system, debugging a C application is extremely inconvenient. In order to preserve the integrity of the log, the file debugging method can play a significant role. Here is an example: #include <stdio.h> FILE * write_debug_file=NULL; //Write debug information to file void write_Debug_to_file(char *debug_log) { if(write_debug_file==NULL) wirte_debug_file = fopen("debug.txt","wt"); if(write_debug_file==NULL) return; fputs(debug_log,write_debug_file); } int main(void) { int i ; char buf[100]; for(i = 0 ; i < 10 ; i++) { sprintf(buf,"i:%d\n",i); //Write debug information write_Debug_to_file(buf); } if(write_debug_file != NULL) fclose(write_debug_file); return 0 ; } Running results: After we open debug.txt, we can see:
The printed data is saved in this file. We can even write any sentence in the code segment into the log and analyze the problem later. This is a very good debugging tool. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Global call implementation of Vue2.x Picker on mobile terminal
>>: Detailed explanation of IFNULL() and COALESCE() functions to replace null in MySQL
With the rise of mobile terminals such as iPad, p...
Table of contents Use Cases Reactive API related ...
K8s k8s is a cluster. There are multiple Namespac...
This article aims to use the clearest structure t...
Of course, there are many people who hold the oppo...
Regarding how to create this thin-line table, a s...
Recently, I need to query all the fields in a rel...
Use JS to zoom in and out when the mouse is on th...
Table of contents 1. Global beforeEach 1. Global ...
This article shares the installation and configur...
Preface The file system is responsible for organi...
I have recently studied the hollowing effect. bac...
1. Best left prefix principle - If multiple colum...
When the scroll bar is pulled down, the floating ...
Table of contents Global variable globalData Page...