NO

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
General discussions / Re: Searching a string for a single character
« Last post by John Z on January 22, 2023, 11:06:06 am »
I imagine that, because the latin 'B' character has many representation in unicode, the search must compare for different encodings, while the chinese character hasn't any more representation than the chinese encoding.

This is a very good hypothesis, I like it.  So for the next test I should ensure that both are encoded the same for example as  UTF-16.

Thanks frankie!
22
General discussions / Re: Searching a string for a single character
« Last post by frankie on January 21, 2023, 12:05:26 pm »
I imagine that, because the latin 'B' character has many representation in unicode, the search must compare for different encodings, while the chinese character hasn't any more representation than the chinese encoding.
23
User contributions / Re: Vanish Lines
« Last post by MrBcx on January 19, 2023, 03:48:51 pm »
Note: once downloaded and extracted you'll need to edit the provided .van file(s) to change the File path to wherever the installation is placed.  Otherwise you will get an error about loading image into memory....

Edit the top 'File=.....' to the correct path to the .van file.

John Z

I found removing the path entirely, leaving only the filename, was sufficient.
24
User contributions / Re: Vanish Lines
« Last post by John Z on January 19, 2023, 02:05:26 pm »
Note: once downloaded and extracted you'll need to edit the provided .van file(s) to change the File path to wherever the installation is placed.  Otherwise you will get an error about loading image into memory....

Edit the top 'File=.....' to the correct path to the .van file.

John Z
25
User contributions / Re: Vanish Lines
« Last post by HellOfMice on January 18, 2023, 07:00:03 pm »
In this version I use MoveToEx and LineTo to draw the lines. I use LineDDA to find the last point.
So the points are not to the good place.
I tried a Bensenham formula but that is wrong because of Microsoft must use another formula for calculate the slope of the line.

Drawing vanish lines is a problem because there are no parallel lines.
Each line has its own angle.

In the next version I will use the plot function with my own lines computing algo.

For the slope I will use : m = (Y2 - Y1) / (X2 - X1)
The line formula is: Y = aX + b where "a" can be replaced by "m"
and b is b = Y1 - mX1

Many good times in perspective
26
User contributions / Vanish Lines
« Last post by HellOfMice on January 18, 2023, 04:36:09 pm »
Hello the ghosts

A small program to play with vanish lines.
It is an attempt I wanted to see what they can be.

There are two files (*.van) that can be edited with the NotePad.
They contents all the parameters and the description of the image.
The first time set :

[Parameters]
Compute my datas=1
Update my datas=1

It centers the image between the horizon line and the bottom of the screen.
If the image is too hight to fill in this area, it is centered from the top and the bottom of the client area.
27
General discussions / Searching a string for a single character
« Last post by John Z on January 14, 2023, 04:49:35 pm »
So . . .  I guess depending on what preceded my need to search a string for a specific character sometimes I used strchr and sometimes strstr.  This is not an error of course one can certainly search for a single character as "B" for example.  After observing my inconsistency I decided to try to time searching with each method.  Timing with ticks is always tricky because of other system activities but if you do it enough times you will get a sense of which procedure is faster. 
Probably not a surprise to anyone strchr has a slight edge over strstr, maybe less than 3% faster.

Then  I figured why not test wcschr and wcsstr while I was at it.   Since I was using "B"  I just use L"B" . Again wcschr was a bit faster by a small margin maybe < 2% faster.  Now here comes the reason for the post -

I decided to try wcsstr vs wcschr with a character out of the first 256 characters.  Here is where is gets very interesting.
Searching for 号 showed that wcschr was still a bit faster than wcsstr looking for the character.  BUT wait there is more:
The wcschr results appeared to be far far faster than searching with wcschr for a wide B char.

So another test just wcschr for 号 vs. for B.  In repeated testing, finding  号 was about ~200x faster than finding B !!
Here is the basic code but of course you'll not have my Write_to_Log procedure, but it is enough if you want to try this yourself.  Yes it ran 3 times at 9 million searches each time, also checked that it was actually found at the end...
Of course if you ran it just once you'll never notice the difference.....

Code: [Select]

 long long loup;
 wchar_t tmp[2000], *p_tmp; p_tmp = tmp;
 wchar_t tmp3[2000], *p_tmp3; p_tmp3 = tmp3;
 wchar_t *p_found=NULL;

 for (loup = 0;loup<1001; loup++)
    {p_tmp[loup] = L'称'; }
 p_tmp[1001] = L'号';p_tmp[1002] = 0;

 for (loup = 0;loup<1001; loup++)
    {p_tmp3[loup] = L'A';}
 p_tmp3[1001] = L'B';p_tmp[1002] = 0;
int oloup;

for (oloup=0;oloup<3; oloup++)
{
Write_To_Log("C://temp//trace.log","Start wcschr uni B",TRUE,0);
for (loup=0; loup < 9000000; loup++)
  { p_found = wcschr(p_tmp3,L'B'); }
Write_To_Log("C://temp//trace.log","End wcschr uni B",TRUE,0);
if (p_found == NULL)
  { Write_To_Log("C://temp//trace.log","wcschr uni not found",FALSE,0);}

p_found = NULL;
Write_To_Log("C://temp//trace.log","Start wcschr uni 号",TRUE,0);
for (loup=0; loup < 9000000; loup++)
  { p_found = wcschr(p_tmp,L'号'); }
Write_To_Log("C://temp//trace.log","End wcschr uni 号",TRUE,0);
if (p_found == NULL)
  { Write_To_Log("C://temp//trace.log","wcschr uni not found",FALSE,0);}

}

Why is wcschr for 号 so much faster than wcschr for B ??

ANYWAY - maybe this will stir up the forum  ;D

Happy New Year,
John Z
28
I think, there simply is the letter "f" missing in front of "reopen" (The Help-File is  affected although) ...

Me too...  ;)
29
General discussion / Re: Who pays and how much to use Pelles C?
« Last post by RKSJBeck on January 03, 2023, 10:12:17 pm »
I contribute on and off.
I try to remember to do it at the end of every year.
30
Pelles C 11.00.2
Code to reproduce ...

#undef _UNICODE
#include <stdio.h>
#include <wchar.h>
#include <tchar.h>

int _tmain( void ) {
   FILE *f = _tfreopen(_T("NUL:"), _T("w"), stdout);
   return 0;
}

Compiler-Output

> > pocc.exe -Tx64-coff -std:C99 -Ob1 -fp:precise -W2 -Gd -Go -GX "O:\Sources\test64\test64.c" -Fo"O:\Sources\test64\output\test64.obj"
O:\Sources\test64\test64.c(7): warning #2018: Undeclared function 'reopen' (did you mean: freopen?); assuming 'extern' returning 'int'.
O:\Sources\test64\test64.c(7): error #2082: Invalid initialization type; expected 'FILE (aka (incomplete) struct FILE) *' but found 'int'.
O:\Sources\test64\test64.c(7): error #2168: Operands of '=' have incompatible types 'FILE (aka (incomplete) struct FILE) *' and 'int'.
*** Error code: 1 ***
Done.

tchar.h Line 360

/* file access */
#define _tfdopen  _fdopen  /* 05-07-18 */
#define _tfopen  fopen  /* 05-07-18 */
#define _tfreopen  reopen  /* 05-07-18 */  <<< Line 360

I think, there simply is the letter "f" missing in front of "reopen" (The Help-File is  affected although) ...
Pages: 1 2 [3] 4 5 ... 10