(_) snprintf cross-platform testing

Source: Internet
Author: User
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main ()
{
Char a[10];

Memset (A, 255, 10);

#如果win

_snprintf (A, 2, "SS");

#如果linux

Snprintf (A, 2, "SS");

#如果结束

printf ("%d%d%d\n", a[0], a[1], a[2]);
System ("pause");
return 0;

}

Results

Print at WIN 115 115-1

Printing under Linux 115 0-1

Description of the problem

1, Linux under the snprintf generated is a string, win is not.

2, (_) snprintf function The second parameter is the length that the function may modify.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

(_) snprintf cross-platform testing

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.