Pages: [1]   Go Down
Author Topic: Changing one char of a char array  (Read 446 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am having a problem with this little snippet of code:
Code:
 
    switch (IRvalue) {
      case rem0:
        Serial.println("0 pressed");
        value[pos] = '0';
        IRvalue = remright;
        GLCD.Puts(value);
        break;
      case rem1:
        Serial.println("1 pressed");
        Serial.print("Value : "); Serial.print(value); Serial.print("  at pos : "); Serial.println(pos, DEC);
        Serial.println(" ");
        Serial.println(" ");
        value[pos] = '1';
        Serial.print("Value : "); Serial.print(value); Serial.print("  at pos : "); Serial.println(pos, DEC);
        Serial.println(" ");
        Serial.println(" ");
        IRvalue = remright;
        GLCD.Puts(value);
        break;
      case rem2:

In the above code,  value  is a char array of length 11 and   pos   is an integer for the current location in an input routine.  The value  IRvalue  is the infra red value coming from the remote.....

Anyway,  the line   value[pos] = '1';   has the effect of making the array value[] blank !!
« Last Edit: May 11, 2011, 03:58:46 am by cowasaki » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25808
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If the value of "pos" is zero, that's what I would expect.

(well, not actually "blank", but "terminate")
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is very strange but it is now working and I have no idea why it didn't last night!
Logged

Pages: [1]   Go Up
Jump to: