size

Does the C standard require the size of an array of n elements to be n times the size of an element?

倖福魔咒の 提交于 2019-11-30 08:10:44
Does the C standard require that the size of an array of n elements be n times the size of an element, either by explicit statement or by rigorous logical deduction from its requirements? For example, could int (*x)[5] = malloc(5 * sizeof **x); fail to request sufficient space for an array of five int ? C 2011 [N1570] 6.5.3.4 7 shows an example of computing the number of elements in an array as sizeof array / sizeof array[0] . However, examples are not a normative part of the standard (per paragraph 8 of the forward). 6.2.5 20 says an array type describes a contiguously allocated nonempty set

UIPickerView won't allow changing font name and size via delegate's `attributedTitleForRow…`

ⅰ亾dé卋堺 提交于 2019-11-30 08:02:34
I use the following func to change the font color and font size, the color works but the font name and font size refuse to work. func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Arial-BoldMT", size: 45)!, NSForegroundColorAttributeName:UIColor.whiteColor()]) any help? Thx. I have a another option may be it helpfull for you.. Do all work that need for normal picker view : for more help UIPickerView make in Swift iOS Now

WPF/Silverlight XAML Stretch Text Size to Fit container?

只愿长相守 提交于 2019-11-30 07:58:31
I've just started to play with WPF. Is it possible to have the size of the text of a Label or TextBlock size itself to fill it's parent container? Thanks, Mark You can use a ViewBox to visually zoom something to fit within its container. The other solutions here work, but they only stretch the control, not its content. The ViewBox will stretch both. <!-- Big grid, will stretch its children to fill itself --> <Grid Width="1000" Height="1000"> <!-- The button is stretched, but its text remains teeny tiny --> <Button> <!-- The viewbox will stretch its content to fit the final size of the button -

Printing HTML5 Canvas in the correct size

北城余情 提交于 2019-11-30 07:36:06
Is there a correct way to specify the size of a canvas element in for example millimeters so that if I print it out it will have the correct size? I've tried this simple example: <!DOCTYPE html> <html> <body> <canvas id="myCanvas" style="border:1px solid #c3c3c3; width:50mm; height:50mm;"> Your browser does not support the HTML5 canvas tag. </canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF0000"; ctx.fillRect(0,0,150,75); </script> </body> </html> But on screen the canvas is 45mm instead of 50mm and when printed its 55mm ^^ Part 1

C++ Get Total File Line Number

痞子三分冷 提交于 2019-11-30 07:34:56
问题 Is there a function I can use to get total file line number in C++ , or does it have to be manually done by for loop? #include <iostream> #include <ifstream> ifstream aFile ("text.txt"); if (aFile.good()) { //how do i get total file line number? } text.txt line1 line2 line3 回答1: There is no such function. Counting can be done by reading whole lines std::ifstream f("text.txt"); std::string line; long i; for (i = 0; std::getline(f, line); ++i) ; A note about scope, variable i must be outside

Constraining proportions of GUI elements in Spritekit game

我与影子孤独终老i 提交于 2019-11-30 07:30:02
I apologize in advance because of huge post, but everybody who ever tried to make some kind of universal app knows that this is pretty problematic stuff, so please be easy on me... The goal What I am trying to achieve (shown on image above) is to use @2x assets on both iPhone 5 and 6, and maintain same look of an app. And if possible, to do all that without manually calculating scale and position properties of nodes based on detected device... So in short, how to achieve that app automatically constrain proportions of, and between elements (and scene)? Also I would like to have same look of an

How do I get the size of a directory in C?

青春壹個敷衍的年華 提交于 2019-11-30 07:20:57
Is there a POSIX function that will give me the size of a directory (including all sub-folders), roughly equivalent to " du -s somepath "? $ man nftw NAME ftw , nftw - file tree walk DESCRIPTION ftw() walks through the directory tree that is located under the directory dirpath, and calls fn() once for each entry in the tree. By default, directories are handled before the files and subdirectories they contain (pre-order traversal). CONFORMING TO POSIX.1-2001, SVr4, SUSv1. Simple example #include <stdio.h> #include <errno.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> static

How to know the length of NSString that fits a UILabel with fixed size?

喜你入骨 提交于 2019-11-30 07:07:29
I know NSString has methods that determine the frame size for it, using NSString UIKit Additions, sizeWithFont...... How about the other way around? I mean if I have a fixed frame size, how do I know how many characters or words for a NSString that can fit into it? If I know this, I can cut off the NSString easily. thanks It might not be the most elegant solution, but you could do something like this: - (NSString *)string:(NSString *)sourceString reducedToWidth:(CGFloat)width withFont:(UIFont *)font { if ([sourceString sizeWithFont:font].width <= width) return sourceString; NSMutableString

setState() or markNeedsBuild called during build

人盡茶涼 提交于 2019-11-30 06:57:16
问题 class MyHome extends StatefulWidget { @override State<StatefulWidget> createState() => new MyHomePage2(); } class MyHomePage2 extends State<MyHome> { List items = new List(); buildlist(String s) { setState(() { print("entered buildlist" + s); List refresh = new List(); if (s == 'button0') { refresh = [ new Refreshments("Watermelon", 250), new Refreshments("Orange", 275), new Refreshments("Pine", 300), new Refreshments("Papaya", 225), new Refreshments("Apple", 250), ]; } else if (s == 'button1

SpriteKit how to get correct screen size

ⅰ亾dé卋堺 提交于 2019-11-30 05:44:57
问题 I've tried self.frame.size self.view!.frame.size UIScreen.mainScreen().bounds.size None of them work. How do I get the correct screen size for the device? 回答1: You can use following swift code to get the screen size. let displaySize: CGRect = UIScreen.mainScreen().bounds let displayWidth = displaySize.width let displayHeight = displaySize.height 回答2: You can use: let deviceWidth = UIScreen.mainScreen().bounds.width let deviceHeight = UIScreen.mainScreen().bounds.height And if you need to get