Skip to main content
Commonmark migration
Source Link

I have a problem and I can't fix it. I'm busy with an java to arduino project.

Java writes a string using writeString(); Arduino reads the serial monitor and put the incoming string into a function.

then I want to put the string into a variable and the variable into a char arr[];

The problem is: When I put the string directly in the arr[]; it works, but when I put first the incoming string in a variable and then the variable in the arr[]; it gives me the next error:

string-parser:44: error: array must be initialized with a brace-enclosed initializer

 

exit status 1

 

initializer fails to determine size of 'arr'

this is the code that doesnt work:

input = "2,5>2,6>2,7>4,8";

String splitStringIntoCoordinates(String input){
  char arr[] = input; // Place incoming route in char array
}

This is the code that does work:

String splitStringIntoCoordinates(String input){
  char arr[] = "2,5>2,6>2,7>4,8"; // Place incoming route in char array
}

I hope anyone can help me. Thanks!

I have a problem and I can't fix it. I'm busy with an java to arduino project.

Java writes a string using writeString(); Arduino reads the serial monitor and put the incoming string into a function.

then I want to put the string into a variable and the variable into a char arr[];

The problem is: When I put the string directly in the arr[]; it works, but when I put first the incoming string in a variable and then the variable in the arr[]; it gives me the next error:

string-parser:44: error: array must be initialized with a brace-enclosed initializer

 

exit status 1

 

initializer fails to determine size of 'arr'

this is the code that doesnt work:

input = "2,5>2,6>2,7>4,8";

String splitStringIntoCoordinates(String input){
  char arr[] = input; // Place incoming route in char array
}

This is the code that does work:

String splitStringIntoCoordinates(String input){
  char arr[] = "2,5>2,6>2,7>4,8"; // Place incoming route in char array
}

I hope anyone can help me. Thanks!

I have a problem and I can't fix it. I'm busy with an java to arduino project.

Java writes a string using writeString(); Arduino reads the serial monitor and put the incoming string into a function.

then I want to put the string into a variable and the variable into a char arr[];

The problem is: When I put the string directly in the arr[]; it works, but when I put first the incoming string in a variable and then the variable in the arr[]; it gives me the next error:

string-parser:44: error: array must be initialized with a brace-enclosed initializer

exit status 1

initializer fails to determine size of 'arr'

this is the code that doesnt work:

input = "2,5>2,6>2,7>4,8";

String splitStringIntoCoordinates(String input){
  char arr[] = input; // Place incoming route in char array
}

This is the code that does work:

String splitStringIntoCoordinates(String input){
  char arr[] = "2,5>2,6>2,7>4,8"; // Place incoming route in char array
}

I hope anyone can help me. Thanks!

Source Link
Dennis
  • 103
  • 1
  • 3

Arduino: put string through variable in array

I have a problem and I can't fix it. I'm busy with an java to arduino project.

Java writes a string using writeString(); Arduino reads the serial monitor and put the incoming string into a function.

then I want to put the string into a variable and the variable into a char arr[];

The problem is: When I put the string directly in the arr[]; it works, but when I put first the incoming string in a variable and then the variable in the arr[]; it gives me the next error:

string-parser:44: error: array must be initialized with a brace-enclosed initializer

exit status 1

initializer fails to determine size of 'arr'

this is the code that doesnt work:

input = "2,5>2,6>2,7>4,8";

String splitStringIntoCoordinates(String input){
  char arr[] = input; // Place incoming route in char array
}

This is the code that does work:

String splitStringIntoCoordinates(String input){
  char arr[] = "2,5>2,6>2,7>4,8"; // Place incoming route in char array
}

I hope anyone can help me. Thanks!