This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MID$

Does keil software have an equivalent to basics MID$

a = "testing"
b = MID$(a,3,2) //b would = st

Parents
  • You question is kind of like asking what's the French word for "the". It could be "Le", "La", or "Les". There is no one-to-one conversion.

    First, the C language does not have a string type. So, there are no functions that work on strings the way they do in basic.

    Second, in C, you use an array of characters to hold a string. It is a string, but to the language and to the programmer it is an array of characters.

    The following example program will do in C what the mid function in basic does.

    char a[] = "testing";
    char b[10];
    
    strncpy (b, a[2], 2);
    

    If you don't already understand the simple data types in C, you should get a copy of the K&R book and read it to learn C.

    Jon

Reply
  • You question is kind of like asking what's the French word for "the". It could be "Le", "La", or "Les". There is no one-to-one conversion.

    First, the C language does not have a string type. So, there are no functions that work on strings the way they do in basic.

    Second, in C, you use an array of characters to hold a string. It is a string, but to the language and to the programmer it is an array of characters.

    The following example program will do in C what the mid function in basic does.

    char a[] = "testing";
    char b[10];
    
    strncpy (b, a[2], 2);
    

    If you don't already understand the simple data types in C, you should get a copy of the K&R book and read it to learn C.

    Jon

Children