strncpy ในภาษา C, C++

6 Sep 2015,
Share: 

strncpy เป็น function สําหรับ copy string จากตัวแปรต้นทางไปใส่ในตัวแปรปลายทาง

รูปแบบการใช้

char *strncpy(char *dest, const char *src, size_t n)

 Parameter

  • dest —String ปลายทาง
  • src —String ต้นทาง
  • n —จํานวนตัวอักษรของต้นทางที่ต้องการ copy

Example

#include <stdio.h>
#include <string.h>

int main()
{
 char src[] = "This is thitiBlog.com";
 char dest[50];

 memset(dest, '\0', sizeof(dest));
 strncpy(dest, src, 10);

 printf("Final copied string : %s\n", dest);

 return(0);
}

Output:

Final copied string : This is th

Suggestion blogs

สร้าง Dark Web (Onion Site) ด้วย Tor และ nginx

ก่อนอื่นมาทําความรู้จักกับ Tor hidden service กันก่อน Tor hidden service เป็นการซ่อน Service หรือ Website ไม่ให้สามารถเปิดได้ด้วยเครือข่าย Internet ทั่วไป หรือไม่สามารถค้นหาผ่าน Search engine ทั่วไปได้ เรียกกันว่า Deep web และ Dark web โดยจะซ่อน Service หรือ Website ไว้ในเครือข่าย Tor ซึ่งจะสามารถเข้าได้ผ่าน Tor browser และ Url จะลงท้ายด้วย .onion รายละเอียดสามารถกลับไปอ่านจากบทความเรื่อง Deep web และ Dark web ด้านมืดของ Internet

[ภาษาซี] ค่าคงที่ Constant

ค่าคงที่แบ่งออกเป็น 3 ประเภท คือ

Vue.js เริ่มต้น ตอน6 (Computed Properties and Watchers)

ก่อนหน้านี้เราได้เรียนรู้กันไปแล้วว่าใน Template จะจัดการเกี่ยวกับการแสดงผล ซึ่งในบางครั้งเราจําเป็นต้องนํา Logic บางอย่างใส่เข้าไปใน Template ด้วย ซึ่งเราก็จะใส่ไปแบบนี้


Copyright © 2019 - 2025 thiti.dev |  v1.51.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ