Linux and Windows \ r and \ n

Source: Internet
Author: User
Tags strcmp strtok

application void Niuniu (void) {char Buf[16];char *p[6];int i;led_init (); Uart_init (); while (1) {puts ("\r\nuart>"); Gets (BUF) ;//Remove \r\nbuf[strlen (BUF)-2] = ' strtok ';//Strtok function uses global variable p[0] = (buf, ""); for (I=1; P[i-1]!=null; i++) {P[i] = Strtok (NULL, "");} if (strcmp (p[0], "ledon") = = 0) {if (strcmp (p[1], "all") = = 0) {for (i=1; i<5; i++) {led_on (i);}} Else{for (I=1; p[i]!=null; i++) {led_on (*p[i]-48);}}} if (strcmp (p[0], "ledoff") = = 0) {if (strcmp (p[1], "all") = = 0) {for (i=1; i<5; i++) {led_off (i);}} Else{for (I=1; p[i]!=null; i++) {Led_off (*p[i]-48);}}}} #endif///////////Driver # if uart==1void uart_init (void) {//select GPH2 and GPH3 features Uartgph.gphcon = ((~ (0xf<<4)) &gph. Gphcon) | (0xa<<4);//Configuration UART0 for, 8-bit data, no checksum, 1-bit stop bit, normal mode uart0.ulcon0 = 0x3;//configuration UART0 for, interrupt or patrol mode Uart0.ucon0 = 0x5;//configuration UART0 for, Baud rate 9600//12m/(9600*16) -1uart0. UBRDIV0 = 0x4d;} void Putc (char c) {//data is placed in the send hold register, and then in the baud rate coordination, the send shifter sends the data in the hold register to a one-out uart0.utxh0 = c;//waits for the data in the send hold register to be sent while (!) UART0. utrstat0& (0x1<<1)) {}}void puts (char *s) {while(*s! = ') {PUTC (*s++);}} Char getc (void) {while (! ( UART0. utrstat0& (0x1<<0)) {}return UART0. URXH0;} void gets (char *s) {///Kermit when you press ENTER, send \rdo{*s = GETC ();//Kermit does not display the data it sends PUTC (*S);} while (*s++! = ' \ r ');//Kermit software \ r \ n Carriage return \ NAND The carriage return is only one \ n, but it has two effects. _______________________________________________________________________________*s++ = ' \ n ';//puts need \0*s = ' + ';} #endif//////////////////////////////linux down \ R for carriage return (back to the beginning of the line) \ nthe puts ("\ r \ n uart>") for newline (next line, current position);//call puts function directly,   The rear automatically has a \0char buf[16]; Get (BUF), when you Kermit under the active input LeDon 1 o'clock, will be automatically obtained by this function, but the acquisition is LeDon \ r (\ r is you in the Kermit environment, you press ENTER to add to the) then the GET function will automatically add a \n\0.////behind Puts (">>>>>\r1234"); Puts ("<<<<<<\r\n5678"); Puts ("+++++++\ntttt"); results 1234<<<<<<5678++++++++++++ Tttt//////////////////////////windos Environment , write a yan.txt when entering a 1, enter, when entering a 2, enter, when entering a 3, save the exit. And put it in Linux, command od-c yan.txt results 1 \ r \ n 2 \ n 3 command ls-l |grep yan.txt-rwxr-xr-x 1 LH LH 7 2014 -09-18 09:01 yan.txt is only seven bytes. Linux environment, write a piao when entering a 1, enter, when entering a 2, enter, when entering a 3, save the exit.   (This does not enter a carriage return) command ls-l |grep piao Results-rw-r--r--1 LH LH 6 2014-09-18 09:07 piao command od-c piao result 1 \ 2 \ n 3 \nlinux Environment, write a piao2 when entering a 1, enter when entering a 2, enter, when entering a 3, the car, save exit.  Command ls-l |grep Piao2 Results-rw-r--r--1 LH LH 7 2014-09-18 09:07 piao command od-c piao2 result 1 \ n 2 \ n 3 \ n

  

Linux and Windows \ r and \ n

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.