Can I assign address of pointer to array ?
Hi,
I want to assign address of pointer to array.
The reason for this is that the pointer would be a global pointer to have the address of a function pointer argument.
Then at task manager I have a main array buffer which holds transmitting data routine.
This is my example:
Code:
#include <stdio.h>#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
uint8_t str_counts, i;
const char *str_ptr;
const char *str1 = {"hi how are you ?"};
uint8_t task_buffer[16];
// functions
void data_print(void);
void write_chars(const char *str);
int main(){
str_counts = strlen(str1);
str_ptr = str1;
//task_buffer = str_ptr;
//printf("%p\n",str1);
//printf("%p\n",str_ptr);
//printf("%p\n",task_buffer);
write_chars(str1);
return 0;
}
void data_print(void){
printf("hi");
task_buffer[0] = str_ptr;
for(i=0; i<str_counts; i++){
printf("%c",task_buffer[i]);
//printf("%c",str_ptr[i]);
}
}
void write_chars(const char *str){
str_ptr = str;
data_print();
}
I commented
Code:
printf("%c",str_ptr[i]);
which is the working line.