Click here to Skip to main content
15,885,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error in returning array of int as reference Pin
leon de boer23-Oct-16 4:24
leon de boer23-Oct-16 4:24 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 8:11
Korowai23-Oct-16 8:11 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 8:26
Korowai23-Oct-16 8:26 
QuestionRe: Error in returning array of int as reference Pin
David Crow23-Oct-16 15:26
David Crow23-Oct-16 15:26 
AnswerRe: Error in returning array of int as reference Pin
Joe Woodbury24-Oct-16 14:07
professionalJoe Woodbury24-Oct-16 14:07 
QuestionMost efficient way to create a string range in C? Pin
Member 1280348819-Oct-16 10:19
Member 1280348819-Oct-16 10:19 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer19-Oct-16 19:33
leon de boer19-Oct-16 19:33 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer20-Oct-16 21:14
leon de boer20-Oct-16 21:14 
I should also say there is a generic form of counting used in encryption that uses sets of characters to numbers.
It isn't fast to code because it requires loops with modulo and divides but it gives you a count in a set of restricted characters or characters in any order.

Consider a set of characters abcABC and that was the digit order like 1,2,3,4,5,6
So counting 0 = a, 1 = b, 2 = c, 3 = A, 4 = B, 5= C, 6 = aa, 7 = ab, 8 = ac, 9 = ba etc

The code to display a count sequence is done like this but I would not call it efficient Smile | :)
static char CodeSet[6] = { 'a', 'b', 'c', 'A', 'B', 'C'};

void CovertCountToCode(char* Buf,  unsigned short BufSize, unsigned long Count) {
	if ((Buf) && (BufSize)) {										// Sanity check on buffer and size
		BOOL notComplete = TRUE;									// Not completed conversion starts true
		unsigned short column = BufSize - 2;						// We start right column for this
		memset(Buf, 0x20, BufSize);									// Clear buffer to spaces
		Buf[BufSize - 1] = '\0';									// Terminate string
		do {
			unsigned short digit = Count % _countof(CodeSet);		// Modulo to set size to get "digit"
			Buf[column] = CodeSet[digit];							// Transfer the character at set position
			column--;												// Move a column left
			if (Count >= _countof(CodeSet)) {						// If we will need to loop again
				Count /= _countof(CodeSet);							// Divid by set size
				Count--;											// Subtract one  
			} else notComplete = FALSE;								// Loop is now complete
		} while ((notComplete) && (column > 0));					// Loop until complete or out of buffer room
	}
}

void CountInCode(unsigned short MaxCount) {
	char Buf[10];													// Buffer for our display text to build
	unsigned short i;
	for (i = 0; i < MaxCount; i++) {								// For each count
		CovertCountToCode(Buf, _countof(Buf), i);					// Convert count to display text
		printf("Code string = %s\r\n", Buf);						// Print the display text
	}
}

// Code to display first 50 counts .. which will be  ... a to abb
CountInCode(50);

In vino veritas

AnswerRe: Most efficient way to create a string range in C? Pin
Joe Woodbury26-Oct-16 12:16
professionalJoe Woodbury26-Oct-16 12:16 
QuestionHow to invoke Printing Preferences for the given Printer programmatically? Pin
purnachandra505016-Oct-16 17:48
purnachandra505016-Oct-16 17:48 
SuggestionRe: How to invoke invoke Printing Preferences for the given Printer programmatically? Pin
Richard MacCutchan17-Oct-16 5:06
mveRichard MacCutchan17-Oct-16 5:06 
QuestionHelp please Memoized rod cutting in C while showing the length it is cut Pin
Member 1279667016-Oct-16 12:03
Member 1279667016-Oct-16 12:03 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
leon de boer16-Oct-16 16:12
leon de boer16-Oct-16 16:12 
GeneralRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
Richard MacCutchan17-Oct-16 5:08
mveRichard MacCutchan17-Oct-16 5:08 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
Richard MacCutchan16-Oct-16 21:25
mveRichard MacCutchan16-Oct-16 21:25 
QuestionAssigning pointers from one class to another and Pin
Vaclav_14-Oct-16 6:23
Vaclav_14-Oct-16 6:23 
AnswerRe: Assigning pointers from one class to another and Pin
leon de boer14-Oct-16 17:58
leon de boer14-Oct-16 17:58 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_15-Oct-16 2:24
Vaclav_15-Oct-16 2:24 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer15-Oct-16 4:42
leon de boer15-Oct-16 4:42 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_15-Oct-16 6:12
Vaclav_15-Oct-16 6:12 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer15-Oct-16 17:16
leon de boer15-Oct-16 17:16 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_19-Oct-16 4:54
Vaclav_19-Oct-16 4:54 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer19-Oct-16 7:45
leon de boer19-Oct-16 7:45 
NewsHow to provide a Security to a proprietary software or presemtation. Pin
Member 1278313512-Oct-16 20:03
Member 1278313512-Oct-16 20:03 
GeneralRe: How to provide a Security to a proprietary software or presemtation. Pin
jeron113-Oct-16 4:15
jeron113-Oct-16 4:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.