1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(その3).構造体で遊ぶ。(memcpyでセット)

Posted at

x M5NanoC6での予定は、未定

目的
ポインターとメモリ操作でmemcpyする

いろいろ
やっぱり、アクセスカウンターが回らなくなった。
ちょっと、難しいかな?
(文法的には、あっていると思う)
(もう少し、改良できるはず?)
(おなかが、減ったので、まっ牛、食べに行こう!!!)


#include <iostream>
#include <string.h>  //memcpy
using namespace std;
int main(void){
    // Your code here!
    printf("START\n");
    
    struct {
        char a;
        char b;
        char c;
    } ABC;
    
    char *c;
    c = (char *)(&ABC);

    memcpy(c, "ABC", 3); 

    printf("a=[%c]\n",ABC.a);
    printf("b=[%c]\n",ABC.b);
    printf("c=[%c]\n",ABC.c);
    
}//main



START
a=[A]
b=[B]
c=[C]

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?