본문 바로가기

728x90
반응형

그 외 코드/C, C++

(5)
[C/C++] Visual Studio BLE(Bluetooth LE) 데이터 읽기 (Window 10) Visual Studio C/C++ 로 BLE 데이터를 읽어 처리하고 싶어 서칭후 발견 & 수정하였습니다. (왜 관련 포스팅이 없는지..ㅠ) 먼저 PC는 블루투스 페어링 하여야 하고, 지정된 UUID를 입력해 데이터를 read할 수 있습니다. 또한 앞서 프로젝트 속성->c/c++->고급->호출 규칙->stdcall 로 바꾸어줍니다. //How to get notification values from a HR BLE monitor //Ensure that you have paired the HR BLE monitor with the computer #include #include #include #include #include #include #include #pragma comment(lib, "Setu..
[C++ gnuplot] Visual Studio로 데이터 받아 2D/3D chart, 그래프 그리기 C++로 차트 그리기 위해 gnuplot 을 사용하였는데요. 사용해보니 gnuplot은 아주 유용한 라이브러리네요. 홈페이지를 참고해주세요. gnuplot을 vs에서 사용하기 위해 먼저 설치를 하고, 설치된 경로를 활용하면 됩니다. 최신버전 설치 설치 경로 입력 gnuplot을 사용한 C++파일은 아래 포스트를 참고하였습니다. blog.daum.net/slo/blog.daum.net/slo/2186 위 파일을 받아서 사용하면 됩니다. // CpGnuplot의 생성자에서 인자로 wgnuplot.exe의 전체 경로를 넘겨준다. // Gnuplot을 설치한 경로에 따라 이 값을 바꿔야 한다. CpGnuplot plot("D:\\gnuplot\\bin\\wgnuplot.exe"); 여기서 gnuplot이 설치된..
[C언어] 십진수 이진수로 바꾸는 코드 코드 #include int main(void) { char buf[8]; int status_error = 100; int status_detail = 220; printf("status_error : 0b"); for (int i = 7; i >= 0; --i) { sprintf(buf, "%d", (status_error >> i) & 1); printf(buf); } printf("\n"); printf("status_detail : 0b"); for (int i = 7; i >= 0; --i) { sprintf(buf, "%d", (status_detail >> i) & 1); printf(buf); } printf("\n"); return 0; } stdout
int, string, char 형변환 string에서 int로 변환 atoi(char ) 함수 사용. 인자가 char*형이기 때문에 c_str()함수로 변환하여 넣어줌. string str = "34"; int a = atoi(str.c_str()); // a = 34; char에서 int로 변환 아스키 코드 활용 char c = '5'; int n = 0; n = c - '0'; // n = 5; int에서 string으로 변환 to_string(int )함수 사용. int n = 35; string str = to_string(n); // str = "35";
[C++] vector 사용 법 라이브러리 추가 #include using namespace std; 성질 맨 뒤에서 삽입과 삭제가 가능 중간에 값을 삽입, 삭제할 수 있음 선언 vector v1; vector v2(5); // 사이즈 5인 벡터 v2 vector v3(5,0); // 0으로 초기화 된 사이즈 5인 벡터 v3 vector v4(v1); // v1을 복사한 벡터 v4vector v2;vector v3; 사용 삽입 v1.push_back(a); v2[3] = a; q = v.insert(p,x); p가 가리키는 자리에 x값 삽입. q는 삽입한 원소 가리키는 반복자 제거 v1.pop_back(); q = v1.erase(p); p가 가르키는 자리 원소 지움. q는 다음 원소 가리키는 반복자 v1.erase(v.begin()+..

728x90
반응형