Search Results

Search found 21759 results on 871 pages for 'int'.

Page 14/871 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • what is size_t in C

    - by benjamin button
    Hi, i am getting confused with size_t in C. i know that it is returned by a sizeof operator. But what exactly it is?Is it a datatype? let's say i have a for loop int i; or size_t i;//which one should i use? for(i=0;i<some_size;i++)

    Read the article

  • When to use typedef?

    - by futlib
    I'm a bit confused about if and when I should use typedef in C++. I feel it's a balancing act between readability and clarity. Here's a code sample without any typedefs: int sum(std::vector<int>::const_iterator first, std::vector<int>::const_iterator last) { static std::map<std::tuple<std::vector<int>::const_iterator, std::vector<int>::const_iterator>, int> lookup_table; std::map<std::tuple<std::vector<int>::const_iterator, std::vector<int>::const_iterator>, int>::iterator lookup_it = lookup_table.find(lookup_key); if (lookup_it != lookup_table.end()) return lookup_it->second; ... } Pretty ugly IMO. So I'll add some typedefs within the function to make it look nicer: int sum(std::vector<int>::const_iterator first, std::vector<int>::const_iterator last) { typedef std::tuple<std::vector<int>::const_iterator, std::vector<int>::const_iterator> Lookup_key; typedef std::map<Lookup_key, int> Lookup_table; static Lookup_table lookup_table; Lookup_table::iterator lookup_it = lookup_table.find(lookup_key); if (lookup_it != lookup_table.end()) return lookup_it->second; ... } The code is still a bit clumsy, but I get rid of most nightmare material. But there's still the int vector iterators, this variant gets rid of those: typedef std::vector<int>::const_iterator Input_iterator; int sum(Input_iterator first, Input_iterator last) { typedef std::tuple<Input_iterator, Input_iterator> Lookup_key; typedef std::map<Lookup_key, int> Lookup_table; static Lookup_table lookup_table; Lookup_table::iterator lookup_it = lookup_table.find(lookup_key); if (lookup_it != lookup_table.end()) return lookup_it->second; ... } This looks clean, but is it still readable? When should I use a typedef? As soon as I have a nightmare type? As soon as it occurs more than once? Where should I put them? Should I use them in function signatures or keep them to the implementation?

    Read the article

  • asp.net C# Webcam api error

    - by Eyla
    Greeting, I'm tring to use webcam api with asp.net and C#. I included all the library and reverince I needed for that. the original code I'm use was for windows application and I'm trying to convert it to asp.net web application. I have start capturing button when I click it, it should start capturing but it gives me an error. the error at this line: hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, picCapture.Handle.ToInt32(), 0); and the error message is: Error 1 'System.Web.UI.WebControls.Image' does not contain a definition for 'Handle' and no extension method 'Handle' accepting a first argument of type 'System.Web.UI.WebControls.Image' could be found (are you missing a using directive or an assembly reference?) C:\Users\Ali\Documents\Visual Studio 2008\Projects\Conference\Conference\Conference1.aspx.cs 63 117 Conference Please advice!! ................................................ here is the complete code ........................................... using System; using System.Collections; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Runtime.InteropServices; using System.Drawing.Imaging; using System.Net; using System.Net.Sockets; using System.Threading; using System.IO; namespace Conference { public partial class Conference1 : System.Web.UI.Page { #region WebCam API const short WM_CAP = 1024; const int WM_CAP_DRIVER_CONNECT = WM_CAP + 10; const int WM_CAP_DRIVER_DISCONNECT = WM_CAP + 11; const int WM_CAP_EDIT_COPY = WM_CAP + 30; const int WM_CAP_SET_PREVIEW = WM_CAP + 50; const int WM_CAP_SET_PREVIEWRATE = WM_CAP + 52; const int WM_CAP_SET_SCALE = WM_CAP + 53; const int WS_CHILD = 1073741824; const int WS_VISIBLE = 268435456; const short SWP_NOMOVE = 2; const short SWP_NOSIZE = 1; const short SWP_NOZORDER = 4; const short HWND_BOTTOM = 1; int iDevice = 0; int hHwnd; [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")] static extern int SendMessage(int hwnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.AsAny)] object lParam); [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetWindowPos")] static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); [System.Runtime.InteropServices.DllImport("user32")] static extern bool DestroyWindow(int hndw); [System.Runtime.InteropServices.DllImport("avicap32.dll")] static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWndParent, int nID); [System.Runtime.InteropServices.DllImport("avicap32.dll")] static extern bool capGetDriverDescriptionA(short wDriver, string lpszName, int cbName, string lpszVer, int cbVer); private void OpenPreviewWindow() { int iHeight = 320; int iWidth = 200; // // Open Preview window in picturebox // hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, picCapture.Handle.ToInt32(), 0); // // Connect to device // if (SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) == 1) { // // Set the preview scale // SendMessage(hHwnd, WM_CAP_SET_SCALE, 1, 0); // // Set the preview rate in milliseconds // SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0); // // Start previewing the image from the camera // SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, 0); // // Resize window to fit in picturebox // SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, iWidth, iHeight, (SWP_NOMOVE | SWP_NOZORDER)); } else { // // Error connecting to device close window // DestroyWindow(hHwnd); } } private void ClosePreviewWindow() { // // Disconnect from device // SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0); // // close window // DestroyWindow(hHwnd); } #endregion protected void Page_Load(object sender, EventArgs e) { } protected void btnStart_Click(object sender, EventArgs e) { int iDevice = int.Parse(device_number_textBox.Text); OpenPreviewWindow(); } } }

    Read the article

  • processing: convert int to byte

    - by inspectorG4dget
    Hello SO, I'm trying to convert an int into a byte in Processing 1.0.9. This is the snippet of code that I have been working with: byte xByte = byte(mouseX); byte yByte = byte(mouseY); byte setFirst = byte(128); byte resetFirst = byte(127); xByte = xByte | setFirst; yByte = yByte >> 1; port.write(xByte); port.write(yByte); According to the Processing API, this should work, but I keep getting an error at xByte = xByte | setFirst; that says: cannot convert from int to byte I have tried converting 128 and 127 to they respective hex values (0x80 and 0x7F), but that didn't work either. I have tried everything mentioned in the API as well as some other blogs, but I feel like I'm missing something very trivial. I would appreciate any help. Thank you.

    Read the article

  • Identify which AlertDialog triggered onClick(DialogInterface dialog, int which)

    - by Kurian
    I'm creating a dialog as follows: @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_1: return new AlertDialog.Builder(this) .setTitle(R.string.s_dlg1) .setPositiveButton(android.R.string.ok, this) .create(); case DIALOG_2: ... ... } return null; } @Override public void onClick(DialogInterface dialog, int whichButton) { if (dialog == ???) { ... } else if (dialog == ???){ ... } } How do I identify which dialog triggered the onClick method? I can't declare the interface methods as in-line when creating the dialog because I want to access variables in my class. Every other interface passes some sort of id to its methods to identify which object called the method, but I can't seem to do anything with 'DialogInterface dialog'.

    Read the article

  • Webcam api error when accessed from ASP.NET Server-side code

    - by Eyla
    I'm tring to use webcam api with asp.net and C#. I included all the library and references I needed for that. the original code I'm use was for windows application and I'm trying to convert it to asp.net web application. I have start capturing button when I click it, it should start capturing but it gives me an error. the error at this line: hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, picCapture.Handle.ToInt32(), 0); and the error message is: Error 1 'System.Web.UI.WebControls.Image' does not contain a definition for 'Handle' and no extension method 'Handle' accepting a first argument of type 'System.Web.UI.WebControls.Image' could be found (are you missing a using directive or an assembly reference?) C:\Users\Ali\Documents\Visual Studio 2008\Projects\Conference\Conference\Conference1.aspx.cs 63 117 Conference Please advice!! ................................................ here is the complete code ........................................... using System; using System.Collections; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Runtime.InteropServices; using System.Drawing.Imaging; using System.Net; using System.Net.Sockets; using System.Threading; using System.IO; namespace Conference { public partial class Conference1 : System.Web.UI.Page { #region WebCam API const short WM_CAP = 1024; const int WM_CAP_DRIVER_CONNECT = WM_CAP + 10; const int WM_CAP_DRIVER_DISCONNECT = WM_CAP + 11; const int WM_CAP_EDIT_COPY = WM_CAP + 30; const int WM_CAP_SET_PREVIEW = WM_CAP + 50; const int WM_CAP_SET_PREVIEWRATE = WM_CAP + 52; const int WM_CAP_SET_SCALE = WM_CAP + 53; const int WS_CHILD = 1073741824; const int WS_VISIBLE = 268435456; const short SWP_NOMOVE = 2; const short SWP_NOSIZE = 1; const short SWP_NOZORDER = 4; const short HWND_BOTTOM = 1; int iDevice = 0; int hHwnd; [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")] static extern int SendMessage(int hwnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.AsAny)] object lParam); [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetWindowPos")] static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags); [System.Runtime.InteropServices.DllImport("user32")] static extern bool DestroyWindow(int hndw); [System.Runtime.InteropServices.DllImport("avicap32.dll")] static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWndParent, int nID); [System.Runtime.InteropServices.DllImport("avicap32.dll")] static extern bool capGetDriverDescriptionA(short wDriver, string lpszName, int cbName, string lpszVer, int cbVer); private void OpenPreviewWindow() { int iHeight = 320; int iWidth = 200; // // Open Preview window in picturebox // hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, picCapture.Handle.ToInt32(), 0); // // Connect to device // if (SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) == 1) { // // Set the preview scale // SendMessage(hHwnd, WM_CAP_SET_SCALE, 1, 0); // // Set the preview rate in milliseconds // SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0); // // Start previewing the image from the camera // SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, 0); // // Resize window to fit in picturebox // SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, iWidth, iHeight, (SWP_NOMOVE | SWP_NOZORDER)); } else { // // Error connecting to device close window // DestroyWindow(hHwnd); } } private void ClosePreviewWindow() { // // Disconnect from device // SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0); // // close window // DestroyWindow(hHwnd); } #endregion protected void Page_Load(object sender, EventArgs e) { } protected void btnStart_Click(object sender, EventArgs e) { int iDevice = int.Parse(device_number_textBox.Text); OpenPreviewWindow(); } } }

    Read the article

  • Java: initialization problem with private-final-int-value and empty constructor

    - by HH
    $ javac InitInt.java InitInt.java:7: variable right might not have been initialized InitInt(){} ^ 1 error $ cat InitInt.java import java.util.*; import java.io.*; public class InitInt { private final int right; InitInt(){} public static void main(String[] args) { // I don't want to assign any value. // just initialize it, how? InitInt test = new InitInt(); System.out.println(test.getRight()); // later assiging a value } public int getRight(){return right;} } Initialization problem with Constructor InitInt{ // Still the error, "may not be initialized" // How to initialise it? if(snippetBuilder.length()>(charwisePos+25)){ right=charwisePos+25; }else{ right=snippetBuilder.length()-1; } }

    Read the article

  • Objective-C: How to create a method that will return a UInt8 array from an int

    - by Adam
    I need to create an Objective-C method that converts an int into a byte array. In this instance, I can't use NSArray as a return type, it must be an UInt8 array. I've written a simple method to do this, but it has errors during compile and tells me that I have incompatible return types. Here is the code snippet. Any ideas? - (UInt8[])ConvertToBytes:(int) i { UInt8 *retVal[4]; retVal[0] = i >> 24; retVal[1] = i >> 16; retVal[2] = i >> 8; retVal[3] = i >> 0; return retVal; }

    Read the article

  • Convert Option[Object] to Option[Int] Implicitly

    - by wheaties
    I'm working with legacy Java code which returns java.lang.object. I'm passing it into a function and I'd like to do some implicit conversions as such: implicit def asInt( _in:Option[Object] ) = _in asInstanceOf[ Option[Int] ] implicit def asDouble( _in:Option[Object] = _in asInstanceOf[ Option[Double] ] private def parseEntry( _name:String, _items:Map[String,Object] ) = _name match{ case docName.m_Constants => new Constants( _items get( Constants m_Epsilon ), _items get( Constant m_Rho ), _items get( Constants m_N ) ) Technically it goes on but I keep getting the same errors: expected Int, Option[Object] found. How have I done my implicits wrong? I was hoping it would do the transformation for me instead of me having to write "asInstanceOf" each and every time.

    Read the article

  • mysql medium int vs. int performance?

    - by aviv
    Hi, I have a simple users table, i guess the maximum users i am going to have is 300,000. Currently i am using: CREATE TABLE users ( id INT UNSIGEND AUTOINCEREMENT PRIMARY KEY, .... Of course i have many other tables that the users(id) is a FOREIGN KEY in them. I read that since the id is not going to use the full maximum of INT it is better to use: MEDIUMINT and it will give better performance. Is it true? (I am using mysql on Windows Server 2008) Thanks.

    Read the article

  • Errors/warnings passing int/char arrays by reference

    - by Ankur Banerjee
    I'm working on a program where I try to pass parameters by reference. I'm trying to pass a 2D int array and a 1D char array by reference. Function prototype: void foo (int* (&a)[2][2], char* (&b)[4]) Function call: foo (a, b); However, when I compile the code with -ansi and -Wall flags on gcc, I get the following errors: foo.c: At top level: error: expected ‘)’ before ‘&’ token error: expected ‘;’, ‘,’ or ‘)’ before ‘char’ foo.c: In function ‘main’: error: too many arguments to function ‘foo’ I've stripped out the rest of the code of my program and concentrated on the bits which throw up the errors. I've searched around on StackOverflow and tried out different ways to pass the parameters, but none of them seem to work. (I took this way of passing parameters from the discussion on StackOverflow here.) Could you please tell me where I'm going wrong?

    Read the article

  • Objective-C : enum like Java (int values and many others for each enum)

    - by Oliver
    In Java, you can make an enum having multiples values. In objective-C, this cannot be done easily. I've read many pages about this but I didn't found anything satisfying that would allow me to use enums by a simple way and to keep the enum declaration and their different values in the same file. I would like to write something like this in a enums.h : // ======================================== typedef enum {eRED, eGREEN, eBLUE} ColorEnum; int colorValues[] = { 0xFF0000, 0x00FF00, 0x0000FF }; NSArray *colorNames = [NSArray arrayWithObjects:@"Red color", @"light green", @"Deep blue", nil]; // ======================================== and be able to use thoses global variables to manage my stuff anywhere like : int color = colorValues[eRED]; But I don't know how to write this. I have compile errors like "ColorValues" is defines many times. Or if I just use "static", I have many "ColorValues" not used in .m file... Could you help me ?

    Read the article

  • Casting a primitive int to a Number

    - by Tamer
    Let's say that I have the following: int a = 2; Number b = (Number) a; System.out.println(b); // Prints 2 http://java.sun.com/docs/books/jls/first_edition/html/15.doc.html#238146 says that a primitive value may not be cast to a reference type. Does Java know to create an Integer from the primitive int and then cast to the superclass? How exactly does Java handle this behind the scenes? Thanks!

    Read the article

  • WPF passing the Int argument to a data object provider method

    - by SAD
    Hi, I'm trying to produce a master/detail datagrid view. I'm using object data providers. Now I have seen many examples when the argument of a method for returning the records for the detail view is a string, like in this example: <!-- the orders datasource --> <ObjectDataProvider x:Key="OrdersDataProvider" ObjectType="{x:Type local:OrdersDataProvider}"/> <ObjectDataProvider x:Key="Orders" MethodName="GetOrdersByCustomer" ObjectInstance="{StaticResource OrdersDataProvider}" > <ObjectDataProvider.MethodParameters> <x:Static Member="system:String.Empty"/> </ObjectDataProvider.MethodParameters> </ObjectDataProvider> But in my case, the argument that I want to pass is the int ID not the string. Can I still somehow use the object data provider to return all the records from the database for the detail view if the argument passed to a method has to be an int? How could it be implemented in MVVM? Thanks a lot for any advice1

    Read the article

  • SQL Server - Compare int values in a select clause

    - by Russell
    This is what I thought would be a simple select clause, however the following is giving me grief! I am using SQL Server 2008. Basically I want to compare two integer values and return the boolean result in the select clause. Here is a simple example: DECLARE @A INT DECLARE @B INT SET @A = 1 SET @B = 2 SELECT @A = @B Currently the only output is "Command(s) completed successfully." Where I reasonably believe it is assigning @A to @B. I thought this would be simple but have not been able to achieve this. Any help would be great! Thanks

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >