c - How to combine two or three characters to one integer/character -


i getting characters uart example "\n43\n" or "\n912\n". intend make integer in order compare values in application.

example:

     int = 43;      int b;      /*combine character getting uart copy integer "b";*/      if(a==b)      {          /*perform operation*/      } 

#include<string.h> #include<stdio.h> int main() { int number; char a[30] = "\n43\n"; number = atoi(a); printf("magic %d",number); if(number == 43)    printf("this works....!\n"); return 0; } 

have heard ever atoi()

edit:

int main() { int number = 0; char a[30]; a[0] = '4'; a[1] = '3'; a[2] = '\0'; number = atoi(a); printf("magic %d",number); return 0; } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -