Multiple values on one serial line

Hello, i have a problem. I need to send multiple numerical values on one line (Create one string in this format "258,335"). Because later i am dividing this string based on the "," in it with javascript, but this is not important. I have came up with this idea:

char* values[300];

void loop(){
   readValues();
}

void readValues() {
    for(int i = 0; i<300; i++){
       values[i] = analogRead(A1) + ',' + analogRead(A2);
      }
    for(int i = 0; i<300; i++){
       Serial.println(values[i]);
      }
  }

But that is giving me some random characters on the serial line which i don't understand.. Does someone know where could be the problem?

What's all that?
How are you going to store all that into a char pointer?

Can you explain why you think that?

    for(int i = 0; i<300; i++){
       Serial.print (analogRead(A1));
       Serial.print (',');
       Serial.println(analogRead(A2));
      }

The value returned by analogRead is a number, not a character.
100 and "100" are extremely different in the world of programming.

But well, below...

for(int i = 0; i < 300; i++)
{
  Serial.print (analogRead(A1));
  Serial.print (',');
  Serial.println(analogRead(A2));
}

Yes, i thought char* notation is for String, because i found out on documentation that char* something[n] creates array of n Strings, so i guess i understood this wrong.. And i thought that values[i] selects ith string from the array, from that point i just wanted to concatenate number from analogRead with ',' this..

yeah, i would be able to do this, but i need to save these lines into an array

so is there maybe a function that reads the last line on the serial so i can save it in array?

No, that would be String*.

char* is for char arrays or strings.

Why would you want to save it?
And where?

Does it make sense to save it as a string?
A value is returned as an int from analogRead, just save it in an int type array.

  1. I want to save them into a array, because i need to read these values from serial with javascript (already taken care of, i know how to do that). I need to slow it down by saving values into array, and then send them into serial with a delay, so they can be handled by the website correctly.
  2. It makes sense to save it as a String, because i'm separating those values with javascript and having them as one String of numbers divided by ',' is easy for me.

If you want to save the values, save them as int values. It will consume 600 bytes.
I don't understand the rest of your reasoning and the "one line" argument.
It makes zero sense (and is potentially impossible) to save the values as a String or even as strings.

i cannot save them as int values, i need them all in one line because i will have up to six analogRead() measurements later in one iteration and all of these six values are related to each other. This is why i need them in a String with format "value1,value2,value3", because it's much easier for me to operate with this format in javascript, where they come as a batch of related values..

The value stored by int is converted to a character string when it is output by Serial.print().
That's what you're already doing.

The JavaScript neither knows nor cares whether the data came from a String, a string or a series of simple prints of an int value

Please, pause and think

That's true, but i know why i need these values in this format, you however don't. so please, if you are trying to help, try understanding my point of view, because this is not a complicated question, i am just asking if there's a way of concatenating numbers into one string and save this string into array. I am really glad that you're trying to help me, but solutions you are offering are just the things i don't want to do.

If true, that could be easily fixed by telling us the reason.

You are perfectly correct - it is not a complicated question.
However, you are making the answer complicated because of your lack of understanding.

okay, i'll tell you the reason why i need to do this.. i thought this isn't important at all, but alright. I am reading single lines from serial line with node.js, when i read a line i would want to seperate this string of numbers into different variables, so i can separately create spot for them in a plot, these are six different traces that are related to each other, reading them from serial as a one batch of data (this string of numbers i was talking about) makes sense to me. But If i was visualizing these values as they are, without "slowing them down" the plotter has it's limits and i don't see AC curves as i see in Arduino plotter, but some weird plot that doesn't look like AC curve at all. That's why i want to record just a part of this unending curve and save them into array, because this allows me to send the same sequence of values with a delay, so the website plotter can keep up. I know it has it's limits, for example if i wanted to loop this, there would always be a lag int the plot, between the iterations, but this doesn't matter to me since i don't have to visualize the data in loop if i don't want to.

Again, we're back to this.
It does not matter that the prints are sent individually, or singly, all that matters is that the print ends with a newline.