memcpy 的使用方法即指针的应用

#include "string.h"

 

uint32_t* app_swap_p = (uint32_t*)FLASH_APP_SWAP_START_ADDR;
    uint32_t* app_p = (uint32_t*)FLASH_APP_START_ADDR;
    uint32_t Address = 0;// = FLASH_APP_SWAP_END_ADDR - FLASH_APP_SWAP_START_ADDR;
    uint32_t app_swap_data = 0, app_data = 0;
    uint32_t error_count = 0;
    error_count = memcmp((uint8_t*)app_swap_p,(uint8_t*)app_p,48*1024);

 

#if 0
    while(Address < (FLASH_APP_SWAP_END_ADDR - FLASH_APP_SWAP_START_ADDR))
    {
        app_swap_data = *(uint32_t*) (app_swap_p);
        app_data      =  *(uint32_t*) (app_p);
        if(app_swap_data != app_data)
        {
            error_count++;
        }   
        Address = Address + 4;
        app_swap_p = app_swap_p + 1;
        app_p = app_p + 1;
    }
    #endif
    if(error_count > 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }   

你可能感兴趣的:(C语言)