Search Results

Search found 6123 results on 245 pages for 'unsigned char'.

Page 193/245 | < Previous Page | 189 190 191 192 193 194 195 196 197 198 199 200  | Next Page >

  • Object reference not set to an instance of an object

    - by Ste
    I have this function that create runtime textbox: int i = 0; private TextBox[] addressBox = new TextBox[100]; private void appendNewTab() { addressBox[i] = new TextBox(); addressBox[i].KeyPress += new KeyPressEventHandler(this.addressBox_KeyPress); i++; } void addressBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { MessageBox.Show(addressBox[i].Text); } } but i have Object reference not set to an instance of an object here MessageBox.Show(addressBox[i].Text); any suggestion?

    Read the article

  • How do I read long lines from a text file in C++?

    - by sonofdelphi
    I am using the following code for reading lines from a text-file. What is the best method for handling the case where the line is greater than the limit SIZE_MAX_LINE? void TextFileReader::read(string inFilename) { ifstream xInFile(inFilename.c_str()); if(!xInFile){ return; } char acLine[SIZE_MAX_LINE + 1]; while(xInFile){ xInFile.getline(acLine, SIZE_MAX_LINE); if(xInFile){ m_sStream.append(acLine); //Appending read line to string } } xInFile.close(); }

    Read the article

  • how to specify a pointer to an overloaded function?

    - by davka
    I want to pass an overloaded function to the std::for_each() algorithm. e.g.: void f(char c); void f(int i); std::string s("example"); std::for_each(s.begin(), s.end(), f); I'd expect the compiler to resolve f() by the iterator type. Apparently, it (gcc 4.1.2) doesn't do it. So, how can I specify which f() I want? thanks a lot

    Read the article

  • GWT : Composite not displaying

    - by animatrix30
    I have a this code for the layout : grid = new Grid(15, 15); tiles = new Tile[15][15]; for (int i = 0; i != 15; i++) { for (int j = 0; j != 15; j++) { tiles[i][j] = new Tile('a'); grid.setWidget(i, j, tiles[i][j]); tiles[i][j].setVisible(true); } } initWidget(grid); I know it is working, because if I change the tile, by a Button, it works well. Now my Tile class : public class Tile extends Composite { char character; public Tile (Character c) { this.character = c; buildWidget(); } private void buildWidget() { Label l = new Label(this.character+""); initWidget(l); } Why does all tiles are not displayed ? Thanks for your help !

    Read the article

  • How does make_pair know the types of its args?

    - by bobobobo
    The definition for make_pair in the MSVC++ "utility" header is: template<class _Ty1, class _Ty2> inline pair<_Ty1, _Ty2> make_pair(_Ty1 _Val1, _Ty2 _Val2) { // return pair composed from arguments return (pair<_Ty1, _Ty2>(_Val1, _Val2)); } I use make_pair all the time though without putting the argument types in angle brackets: map<string,int> theMap ; theMap.insert( make_pair( "string", 5 ) ) ; Shouldn't I have to tell make_pair that the first argument is std::string and not char* ? How does it know?

    Read the article

  • Need help making this code more efficient

    - by Rendicahya
    I always use this method to easily read the content of a file. Is it efficient enough? Is 1024 good for the buffer size? public static String read(File file) { FileInputStream stream = null; StringBuilder str = new StringBuilder(); try { stream = new FileInputStream(file); } catch (FileNotFoundException e) { } FileChannel channel = stream.getChannel(); ByteBuffer buffer = ByteBuffer.allocate(1024); try { while (channel.read(buffer) != -1) { buffer.flip(); while (buffer.hasRemaining()) { str.append((char) buffer.get()); } buffer.rewind(); } } catch (IOException e) { } finally { try { channel.close(); stream.close(); } catch (IOException e) { } } return str.toString(); }

    Read the article

  • How to call a function from a shared library?

    - by Frank
    What is the easiest and safest way to call a function from a shared library / dll? I am mostly interested in doing this on linux, but it would be better if there were a platform-independent way. Could someone provide example code to show how to make the following work, where the user has compiled his own version of foo into a shared library? // function prototype, implementation loaded at runtime: std::string foo(const std::string); int main(int argc, char** argv) { LoadLibrary(argv[1]); // loads library implementing foo std::cout << "Result: " << foo("test"); return 0; } BTW, I know how to compile the shared lib (foo.so), I just need to know an easy way to load it at runtime.

    Read the article

  • Force to reimplement a static function in inherit classes

    - by pacopepe
    Hi, I have a program in C++ with plugins (dynamic libs). In the main program, I want to execute a static function to check if i can create a object of this type. An example without dynamic libs (aren't neccesary to understand the problem): #include "libs/parent.h" #include "libs/one.h" #include "libs/two.h" int main(int argc, char * argv[]) { Parent obj; if (One.match(argv[1])) { obj = new One(); else if (Two.match(argv[1])) { obj = new Two(); } Now, i have a interface class named Parent. All plugins inherit from this class. Ideally, I have a virtual static function in Parent named match, and all the plugins need to reimplement this function. The problem with this code is that i can't do a static virtual function in C++, so i don't know how to solve the problem. Sorry for mi english, i did my best

    Read the article

  • How to get path to current exe file on Linux?

    - by user1519221
    The code below gives current path to exe file on Linux: #include <iostream> std::string getExePath() { char result[ PATH_MAX ]; ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX ); return std::string( result, (count > 0) ? count : 0 ); } int main() { std::cout << getExePath() << std::endl; return 0; } The problem is that when I run it gives me current path to exe and name of the exe, e.g.: /home/.../Test/main.exe I would like to get only /home/.../Test/ I know that I can parse it, but is there any nicer way to do that?

    Read the article

  • Resolve circular typedef dependency?

    - by Nick
    What is the best way to resolve the following circular dependency in typedef-ing these structs? Note the C language tag - I'm looking for a solution in standard gcc C. typedef struct { char* name; int age; int lefthanded; People* friends; } Person; typedef struct { int count; int max; Person* data; } People;

    Read the article

  • C++ open() fails for no apparant reason

    - by jondoe
    The following code: char filename[64]; ifstream input; cout << "Please enter the filename: " << endl; cin >> filename; input.open(filename); if (!input.is_open()) { cout << "Opening file " << filename << " failed." << endl; exit(1); } fails, it enters the if() and exits. What could possibly be the cause for this? I'm using Microsoft Visual C++. When I hardcoded the filename as a constant it instead ended up garbled: http://pici.se/pictures/CNQEnwhgo.png Suggestions?

    Read the article

  • Why does the Win32-API have so many custom types?

    - by sub
    I'm new to the Win32 API and the many new types begin to confuse me. Some functions take 1-2 ints and 3 UINTS as arguments. Why can't they just use ints? What are UINTS? Then, there are those other types: DWORD LPCWSTR LPBOOL Again, I think the "primitive" C types would be enough - why introduce 100 new types? This one was a pain: WCHAR* I had to iterate through it and push_back every character to an std::string as there wasn't another way to convert it to one. Horrible. Why WCHAR? Why reinvent the wheel? They could have just used char* instead, or?

    Read the article

  • C++: use array of strings wrapped in namespace?

    - by John D.
    I got the following code, wishing to wrap a group of strings nicely in a namespace: namespace msgs { const int arr_sz = 3; const char *msg[arr_sz] = {"blank", "blank", "blank" }; msg[0] = "Welcome, lets start by getting a little info from you!\n"; msg[1] = "Alright, bla bla bla.."; msg[2] = "etc."; } The code inside works nicely inside a function, but I don't know how to return an array from it. The namespace idea LOOKS fine, but it returns on the last three lines: error: expected constructor, destructor, or type conversion before ‘=’ token Why can't I define the array inside a namespace, do I need to do something first? It's nice because I can call it like printf(msgs::msg[1]) etc. I want to do this I just can't wrap my head around what's wrong :(

    Read the article

  • How do I remove &#13 ; from my text file using VBScript Replace() or a regex?

    - by Eric Lachance
    Hi! I'm doing a conversion between two software which both use XML so the actual conversion part is fairly straightforward - adding text here, removing others here, converting a few information. I'm using VBSCript WSH. The only issue I'm still having is the darn &#13; character - that's my problem! I've tried both strText = Replace(strText, "&#13;", "") and using a regex with Regex.pattern = "&#13;" ... neither works. I also tried replacing char(13), VBCR... nothing seems to detect the actual string itself and not the character it's creating. Can anyone help me?

    Read the article

  • PHP & MySQL storing multiple values in a database.

    - by R.I.P.coalMINERS
    I'm basically a front end designer and new to PHP and MySQL but I want a user to be able to store multiple names and there meanings in a MySQL database table named names using PHP I will dynamically create form fields with JQuery every time a user clicks on a link so a user can enter 1 to 1,000,000 different names and there meanings which will be stored in a table called names. All I want to know is how can I store multiple names and there meanings in a database and then display them back to the user for them to edit or delete using PHP MySQL? I created the MySQL table already. CREATE TABLE names ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, userID INT NOT NULL, name VARCHAR(255) NOT NULL, meaning VARCHAR(255) NOT NULL, PRIMARY KEY (id) ); Here is the HTML. <form method="post" action="index.php"> <ul> <li><label for="name">Name: </label><input type="text" name="name" id="name" /></li> <li><label for="meaning">Meaning: </label><input type="text" name="meaning" id="meaning" /></li> <li><input type="submit" name="submit" value="Save" /> <input type="hidden" name="submit" value="true" /></li> </ul> </form>

    Read the article

  • Increase a recive buffer in UDP socket

    - by unresolved_external
    I'wm writing an app, which transmits video and obviously uses UDP protocol fot this purpose. So I am wondering how can I increase a size of send/recieve buffer, cause currently the maximal size of data, which I can send is 65000 bytes. I already tried to do it in following way: int option = 262144; if(setsockopt(m_SocketHandle,SOL_SOCKET,SO_RCVBUF ,(char*)&option,sizeof(option)) < 0) { printf("setsockopt failed\n"); } But it did not work. So how can I do it?

    Read the article

  • Initializing a array after declaration

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following code as a sample of what I am trying to do. I don't know the actual size of the array, until I enter the function. However, I don't think I can set the array size after I have declared it. I need it global as some other functions will need to access the device names. Many thanks for any suggestions, /* global */ char *devices_names[]; void fill_devices(size_t num_devices) { devices_names[num_devices]; /* start filling */ }

    Read the article

  • An array of structures in C...

    - by 00010000
    For the life of me I can't figure out the proper syntax for creating an array of structures in C. I tried this: struct foo { int x; int y; } foo[][] = { { { 1, 2 }, { 4, 5 }, { -1, -1 } }, { { 55, 44 } { 100, 200 }, } }; So for example foo[1][0].x == 100, foo[0][1].y == 5, etc. But GCC spits out a lot of errors. If anyone could provide the proper syntax that'd be great. EDIT: Okay, I tried this: struct foo { const char *x; int y; }; struct foo bar[2][] = { { { "A", 1 }, { "B", 2 }, { NULL, -1 }, }, { { "AA", 11 }, { "BB", 22 }, { NULL, -1 }, }, { { "ZZ", 11 }, { "YY", 22 }, { NULL, -1 }, }, { { "XX", 11 }, { "UU", 22 }, { NULL, -1 }, }, }; But GCC gives me "elements of array bar have incomplete type" and "excess elements in array initializer".

    Read the article

  • Why can't i call Contains method from my array?

    - by xbnevan
    Arrrg!I am running into what i feel is a dumb issue with a simple script i'm writing in powershell. I am invoking a sql command that is calling a stored proc, with the results i put it a array. The results look something like this: Status ProcessStartTime ProcessEndTime ------ ---------------- -------------- Expired May 22 2010 8:31PM May 22 2010 8:32PM What i'm trying to do is if($s.Contains("Expired")) , report failed. Simple...? :( Problem i'm running into is it looks like Contains method is not being loaded as i get an error like this: Method invocation failed because [System.Object[]] doesn't contain a method named 'Contains'. At line:1 char:12 + $s.Contains <<<< ("Expired") + CategoryInfo : InvalidOperation: (Contains:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound So, what can i do to stop powershell from unrolling it to string? Actual ps script below - $s = @(Invoke-Sqlcmd -Query "USE DB GO exec Monitor_TEST_ps 'EXPORT_RUN',NULL,20 " ` -ServerInstance "testdb002\testdb_002") if ($s.Contains("Expired")) { Write-Host "Expired found, FAIL." } else { Write-Host "Not found, OK." }

    Read the article

  • creating new array according to input

    - by gcc
    int *arrays[20],j,a=0; /*int num_arrays;*/ char *tutar[200]; int /*fe*/i=0,n,temp; do{ tutar[i]=malloc(sizeof(int)); scanf("%s",tutar[i]); temp=*tutar[i]; ++i; } while(temp!='x'); int *arrays[20],j,a=0; n=i; j=1; for(i=1;i if(atoi(tutar[i])=='n') { ++j; arrays[j]=malloc(sizeof(int)); a=0; } arrays[j][a]=*(int *)tutar[i]; if(atoi(tutar[i])=='x') break; } input: 1 2 3 4 n 14 23 39 n 98 100 x output: arrays[1]:2 3 4 arrays[2]:14 23 39 arrays[3]:98 100 //i wanna output like that but my code didnt give me output like that //can anyone fix my code or (explain where is my error)

    Read the article

  • How to algorithmically partion a keyspace?

    - by pbhogan
    This is related to consistent hashing and while I conceptually understand what I need to do, I'm having a hard time translating this into code. I'm trying to divide a given keyspace (say, 128 bits) into equal sized partitions. I want the upper bound (highest key) of each partition. Basically, how would I complete this? #define KEYSPACE_BYTE_SIZE 16 #define KEYSPACE_BIT_SIZE (KEYSPACE_BYTE_SIZE * 8) typedef struct _key { char byte[KEYSPACE_BYTE_SIZE]; } key; key * partition_keyspace( int num_partitions ) { key * partitions = malloc( sizeof(key) * num_partitions ); // ... }

    Read the article

  • Why does a non-constant offsetof expression work?

    - by Chris J. Kiick
    Why does this work: #include <sys/types.h> #include <stdio.h> #include <stddef.h> typedef struct x { int a; int b[128]; } x_t; int function(int i) { size_t a; a = offsetof(x_t, b[i]); return a; } int main(int argc, char **argv) { printf("%d\n", function(atoi(argv[1]))); } If I remember the definition of offsetof correctly, it's a compile time construct. Using 'i' as the array index results in a non-constant expression. I don't understand how the compiler can evaluate the expression at compile time. Why isn't this flagged as an error?

    Read the article

  • Sending some byte at time

    - by user1417815
    I'm trying to figure out way to send some amount of text from the string ech time until it reach the end of the string, example: const char* the_string = "hello world, i'm happy to meet you all. Let be friends or maybe more, but nothing less" Output: hello world Output: , i'm happy to meet you all. Output: Let be friends or maybe more Output: , but nothing less stop: no more bytes to send. the problem i have searched google, but didn't understand the examples, i spent 4 days trying find a good way, also that sendt 5 bytes at time, but in case there is less, then send them until you are at the end of the string. please help me out guys, i will accept a C or C++ way, as long it works and well explained.

    Read the article

  • Can I use a single pointer for my hash table in C?

    - by aks
    I want to implement a hash table in the following manner: struct list { char *string; struct list *next; }; struct hash_table { int size; /* the size of the table */ struct list **table; /* the table elements */ }; Instead of struct hash_table like above, can I use: struct hash_table { int size; /* the size of the table */ struct list *table; /* the table elements */ }; That is, can I just use a single pointer instead of a double pointer for the hash table elements? If yes, please explain the difference in the way the elements will be stored in the table?

    Read the article

< Previous Page | 189 190 191 192 193 194 195 196 197 198 199 200  | Next Page >