01/10/2018, 14:05

Tại sao lại xuất hiện "ADS" ở màn hình console?

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] == '
') 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
";
	rxData bufferDataProcess;
	char *data = "sdfkjdADS,1,0,1,0
fg,fgdf,gvd";
	char *ID = "ADS";
	
	bufferDataProcess = rxDataProcess(data, ID);

	cout << ID << "
";
	if (bufferDataProcess.data) cout << bufferDataProcess.data << "
";
	cout << bufferDataProcess.len << "
";
	cout << bufferDataProcess.found << "
";

	return(0);
}

Bài liên quan
0