I am new to Arduino and I am currently working with an Arduino Uno and SD card module - SD/MMC for database storage using the Arduino database library from https://github.com/jwhiddon/EDB.

My question is, is the char str[] type the equivalent of VARCHAR?

Here is my arbitrary record definition for my table:

struct LogEvent { 
  int logId;
  int unumber;
  char username[10];
  char fname[15]; 
  char lname[15];
  char role[6];
  char boxid[10];
  char userStatus[2];
} logEvent;
  • 1
    What's VARCHAR? Where is the definition of that? Are you referring to the SQL type?
    – Nick Gammon
    Dec 26, 2017 at 6:27
  • I am referring to SQL type
    – Xirb
    Dec 26, 2017 at 6:53
  • You are asking if a SQL data type VARCHAR is "equivalent" to char str[]? What do you mean by the word "equivalent"? For one thing, SQL VARCHAR has a size associated with it: VARCHAR(size). So no, they are not equivalent.
    – Nick Gammon
    Dec 26, 2017 at 7:24

2 Answers 2


If you mean, are these equivalent:

foo VARCHAR(100);


char foo [100];

No, they are not equivalent, really. In the case of SQL you can put 100 characters into foo. In the case of C++ you would (generally speaking) put up to 99 characters into foo, with the final character being 0x00 which indicates the length of the string.

You could conceivably put 100 characters into foo but then you would have to store the size of foo in another variable.


If you're referring to the SQL type VARCHAR, then, vaguely. char username[10]; for instance will define a char array of 10 bytes. A char being the equivalent of a byte. That's about it for the type. This is C++, so you're pretty close to the iron, and a char array is about as basic as it gets. No collation, no encoding (remember that a character is not always a single byte!), no indexing. Just a bunch of bytes put together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.