Mọi người cho mình hỏi. Tại sao lại xuất hiện “ADS” ở màn hình console
code:
// PoiterFuntion.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <algorithm>
#include <iostream>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
typedef struct rxDatas{
bool found = false;
char * data = NULL;
int len = 0;
}rxData;
rxData rxDataProcess(char *data, char *ID)
{
rxData buffer;
int dataLen = 0;
char * foundID = strstr(data, ID);
if (foundID) buffer.found = true; else return buffer;
for (int i = 0; i <= strlen(foundID); i++) {
if (foundID[i] == '\n') break;
if (foundID[i] == ',') {
//position[dataLen] = i;
printf("%d - ", i);
dataLen++;
}
}
buffer.len = dataLen;
return buffer;
}
int main() {
int day, year;
char weekday[20], month[20], dtm[100];
//unsigned char buffer[50] = "sdfkjdADS,1,0,1,0\n";
rxData bufferDataProcess;
char *data = "sdfkjdADS,1,0,1,0\nfg,fgdf,gvd";
char *ID = "ADS";
bufferDataProcess = rxDataProcess(data, ID);
cout << ID << "\r\n";
if (bufferDataProcess.data) cout << bufferDataProcess.data << "\r\n";
cout << bufferDataProcess.len << "\r\n";
cout << bufferDataProcess.found << "\r\n";
return(0);
}