Type conversion in C + + Xmlchar * with char * conversion, char * with int conversion, char * with float conversion, int vs. portnumbits conversion

Source: Internet
Author: User

Using LIBXML2

Get the contents of a node:
Xmlchar *value = xmlnodegetcontent (node)


1. Convert Xmlchar into Char

char * stream = (char *) value;

2, Char * and int conversion

int x = atoi (stream);

#include "stdio.h" #include "stdlib.h" main () {char *p= "1234567"; int x; X=atoi (P);//Turn into shaping printf ("%d\n", x);} If the landlord is written char*p= "1234.567" is X=atof (p); C Language Library function name: atoi  Function: Converts a string to an integer number.  Name Source: an abbreviation for array to integer.   Function Description: Atoi () scans the parameter nptr string, if the first character is not a number and is not the sign returns zero, otherwise the type conversion is started, then a non-numeric or terminator is detected to stop the conversion, returning the integer number.   prototype: int atoi (const char *nptr);  Header files needed: #include <stdlib.h> atof is the conversion of strings to floating-point numbers
3, Char * and float conversion

char * p = "1234.567";

int x = Atof (p);

4, int and portnumbits conversion

int a = 554;

Portnumbits n = (portnumbits) A



Type conversion in C + + Xmlchar * with char * conversion, char * with int conversion, char * with float conversion, int vs. portnumbits conversion

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.