Assigning a value to pointer_ error 'iamstring' does not name a type



# include <string.h>

int a = 1;
int *iamstring =NULL ;
iamstring = &a; //this assignment makes the error code :  'iamstring' does not name a type

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("first iamstring without *"); 
  Serial.println(iamstring); //suppose to show the memory address
  Serial.println("now iamstring with *");
  Serial.println(*iamstring); //suppose to show the value
}

//thanks for helping

you can't have code outside of function. move the line to setup()

well thank you that was so fast from you :slight_smile:

Why not simply

int *iamstring = &a;

?

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.