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
Table of contents Summarize <template> <...
Table of contents 1. Install the required environ...
Table of contents Preface Introduction JavaScript...
This article shares the specific code of JavaScri...
When using the font-family property in CSS to ref...
In daily operation and maintenance work, nginx se...
Introduction to Docker Docker is an open source a...
background PNG images take up more storage space ...
Table of contents Layout part: <div id="a...
It is very simple to build a kong cluster under t...
Environmental preparation: VMware+CentOS, jdk 1. ...
User and Group Management 1. Basic concepts of us...
Problem Description MySQL is started successfully...
Table of contents Purpose of Teleport How Telepor...
Preface Index Condition Pushdown (ICP) is a new f...