Skip to content

Commit 2c4a063

Browse files
committed
printw_example: Fix build
Using std.conv rather than an ordinary cast for a bit more safety. It rarely hurts to have the checking.
1 parent bcab0a6 commit 2c4a063

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/printw_example.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//Modified by: 1100110
22

3+
import std.conv;
34
import std.string;
45
import deimos.ncurses.ncurses; /* ncurses.h includes stdio.h */
56

@@ -11,7 +12,7 @@ void main()
1112
initscr(); //start the curses mode
1213
getmaxyx(stdscr, row, col); //get the number of rows and columns
1314
//print the message at the center of the screen
14-
mvprintw(row/2, (col-(mesg.length - 1))/2, "%s", toStringz(mesg));
15+
mvprintw(row/2, to!uint((col-(mesg.length - 1))/2), "%s", toStringz(mesg));
1516
//Did you notice? there is a '%s' not toStringified.
1617
//In one of those great weird blips, D2 will pass small characters
1718
//like that, and yet will choke on larger strings.

0 commit comments

Comments
 (0)