Search Results

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

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

  • 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

  • Loading Unmanaged C++ in C#. Error Attempted to read or write protected memory

    - by Thatoneguy
    I have a C++ function that looks like this __declspec(dllexport) int ___stdcall RegisterPerson(char const * const szName) { std::string copyName( szName ); // Assign name to a google protocol buffer object // Psuedo code follows.. Protobuf::Person person; person->set_name(copyName); // Error Occurs here... std::cerr << person->DebugString() << std::endl; } The corresponding C# code looks like this... [DllImport(@"MyLibrary.dll", SetLastError = true)] public static unsafe extern int RegisterPerson([MarshalAs(UnmanagedType.LPTStr)]string szName) Not sure why this is not working. My C++ library is compiled as Multi Threaded DLL with MultiByte encoding. Any help would be appreciated. I saw this is a common problem online but no answers lead me to a solution for my problem.

    Read the article

  • Initializing an 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

  • How to copy a structure with pointers to data inside (so to copy pointers and data they point to)?

    - by Kabumbus
    so I have a structure like struct GetResultStructure { int length; char* ptr; }; I need a way to make a full copy of it meaning I need a copy to have a structure with new ptr poinnting on to copy of data I had in original structure. Is It any how possible? I mean any structure I have which contains ptrs will have some fields with its lengths I need a function that would copy my structure coping all ptrs and data they point to by given array of lengthes... Any cool boost function for it? Or any way how to create such function?

    Read the article

  • Writing different structs to a file in C++? [on hold]

    - by user58053
    I need a way to write structures of three different kinds to a binary file, which later has to be searched. (As in, for example, struct A has two fields, an int and a char; struct B has int and a long; I need to output all structures whose int equals the one given from keyboard). I understand how to write structs of the same kind to a file and how to search them, but here I am just lost, best thing I came up with is declaring a struct containing all possibly needed fields and leaving the ones I don't need empty, but it really feels wrong, there HAS to be a better way to do that. I've read about binary files and could not find anything relevant, most examples and tutorials deal with writing one data type. Could anyone point me in the right direction? EDIT: I am looking for what @Jerry_coffin called database mode, and will probably use one of the existing database systems for that, best way to go, probably. Thank you everybody for the suggestions

    Read the article

  • CString a = "Hello " + "World!"; Is it possible?

    - by Sanctus2099
    I'm making my own string class and I was wondering if there's any way to replace the compiler behaviour around " characters. As I said in the title I'd like to make it so that CString a = "Hello " + "World!"; would actually work and not give a compiler error telling that it can't add 2 pointers. My string class automatically converts to char* when needed and thus writing printf(a) would not break the code. I'm sure this is a rather weird question but if it's possible I'd really like to know how to do it. Thank you very much

    Read the article

  • Regex: Match opening/closing chars with spaces

    - by Israfel
    I'm trying to complete a regular expression that will pull out matches based on their opening and closing characters, the closest I've gotten is ^(\[\[)[a-zA-Z.-_]+(\]\]) Which will match a string such as "[[word1]]" and bring me back all the matches if there is more than one, The problem is I want it to pick up matchs where there may be a space in so for example "[[word1 word2]]", now this will work if I add a space into my pattern above however this pops up a problem that it will only get one match for my entire string so for example if I have a string "Hi [[Title]] [[Name]] [[surname]], How are you" then the match will be "[[Title]] [[Name]] [[surname]]" rather than 3 matches "[[Title]]", "[[Name]]", "[[surname]]". I'm sure I'm just a char or two away in the Regex but I'm stuck, How can I make it return the 3 matches. Thanks

    Read the article

  • xcode 4 creating a 2d grid (range and domain)

    - by user1706978
    I'm learning how to program c and i'm trying to make a program the finds the range (using an equation with x as the domain) of a 2d grid...ive already attempted it, but it's giving me all these errors on Xcode, any help?(As you can see, I'm quite stuck!) #include <stdio.h> #include <stdlib.h> float domain; float domain = 2.0; float domainsol(float x ) { domain = x; float func = 1.25 * x + 5.0; return func; } int main(int argc, const char * argv[]) { }

    Read the article

  • explain notifier.c from the Linux kernel

    - by apollon
    I'm seeking to fully understand the following code snippet from kernel/notifier.c. I have read and built simple link lists and think I get the construct from K&R's C programming. The second line below which begins with the 'int' appears to be two items together which is unclear. The first is the (*notifier_call) which I believe has independent but related significance with the second containing a 'notifier block' term. Can you explain how it works in detail? I understand that there is a function pointer and multiple subscribers possible. But I lack the way to tie these facts together, and could use a primer or key so I exactly understand how the code works. The third line looks to contain the linking structure, or recursive nature. Forgive my terms, and correct them as fit as I am a new student of computer science terminology. struct notifier_block { int (*notifier_call)(struct notifier_block *, unsigned long, void *); struct notifier_block *next; int priority; };

    Read the article

  • C++: how serialize/deserialize objects without any library?

    - by Winte Winte
    I try to understand how serializing/deserializing works in c++, so I want to do that without any libs. But I really stuck with that. I start with simple objects but when I try to deserilize a vector I understand that I can't get a vector without if I don't write it size before. Moreover, I don't know which format of file I should choose because if digits will be existed before size of vector I haven't chance to read it right. However it is only the vector but I also want to do that with classes and map container. My task is serialize/deserialize a objects as this: PersonInfo { unsigned int age_; string name_; enum { undef, man, woman } sex_; } Person : PersonInfo { vector<Person> children_; map<string, PersonInfo> addrBook_; } Currently I know how to serialize simple objects in way as this: vector<PersonInfo> vecPersonInfo; vecPersonInfo.push_back(*personInfo); vecPersonInfo.push_back(*oneMorePersonInfo); ofstream file("file", ios::out | ios::binary); if (!file) { cout<<"can not open file"; } else { vector<PersonInfo>::const_iterator iterator = vecPersonInfo.begin(); for (; iterator != vecPersonInfo.end(); iterator++) { file<<*iterator; } Could you please suggest how I can do this for this conplex object or a good tutorial that explain it clearly?

    Read the article

  • Strange macro declaration in C

    - by Andrey Atapin
    Exploring libusb-1.0.9 source code, I have found such line (./os/poll_windows.c:78): #define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0) As for me this is the same like: #define CHECK_INIT_POLLING if(!is_polling_set) init_polling(); Is there any reason to loop that expression? UPDATE: I couldn't still realize what'd be wrong after the answers, and the following example helped: #include <stdio.h> #define TEST if(test) foo(); #define TEST_DO do { if(test) foo(); } while(0) int test = 1; void foo() { printf("%s", "Foo called"); } int main(int argc, char** argv) { if(argc > 1) TEST_DO; /* LINE 12 */ else printf("%s", "skipping..."); return 0; } If you put TEST at line 12, a compiler will give an error "error: ‘else’ without a previous ‘if’". Hope, this will help someone.

    Read the article

  • Java spliting strings

    - by N0b
    Hi I've got a Java problem. I'm trying split a string when ever a " " occurs, for example the sentence test abc. Then move the first letter in each word from first to last. I got the moving the letter to work on the original string using String text = JOptionPane.showInputDialog(null,"Skriv in en normal text:"); char firstLetter = text.charAt(0); normal = text.substring(1,text.length()+0) + firstLetter; So my question is how would I split the string then start moving the letters around in each part of the cut string? Thanks in advance

    Read the article

  • Read text and print each (byte) character in separate line

    - by user2967663
    preforming this code to read file and print each character \ (byte) in separate line works well with ASCII void preprocess_file (FILE *fp) { int cc; for (;;) { cc = getc (fp); if (cc == EOF) break; printf ("%c\n", cc); } } int main(int argc, char *argv []) { preprocess_file (stdin); exit (0); } but when i use it with UTF-8 encoded text it shows unredable character such as ï » ? ? § ? „ ? … ? ¤ ? ´ ? and advice ? Thanks

    Read the article

  • C Struct as an argument

    - by Brian
    I'm wondering what's the difference between sample1 and sample2. Why sometimes I have to pass the struct as an argument and sometimes I can do it without passing it in the function? and how would it be if samplex function needs several structs to work with? would you pass several structs as an argument? struct x { int a; int b; char *c; }; void sample1(struct x **z;){ printf(" first member is %d \n", z[0]->a); } void sample2(){ struct x **z; printf(" first member is %d \n", z[0]->a); // seg fault } int main(void) { struct x **z; sample1(z); sample2(); return 0; }

    Read the article

  • How to do hex8 encoding in c?

    - by Tech163
    I am trying to encode a string in hex8 using c. The script I have right now is: int hex8 (char str) { str = printf("%x", str); if(strlen(str) == 1) { return printf("%s", "0", str); } else { return str; } } In this function, I will need to add a 0 ahead of the string if the length is less than 1. I don't know why I'm getting: passing argument 1 of 'strlen' makes pointer from integer without a cast Does anyone know why?

    Read the article

  • How to make smooth movements in OpenGL?

    - by thyrgle
    So this kind of on topic to my other OpenGL question (not my OpenGL ES question but OpenGL the desktop version). If you have someone press a key to move a square how do you make the square movement naturally and less jumpy but also at the same speed I have it now? This is my code for the glutKeyboardFunc() function: void handleKeypress(unsigned char key, int x, int y) { if (key == 'w') { for (int i = 0; i < 12; i++) { if (i == 1 || i == 7 || i == 10 || i == 4) { square[i] = square[i] + 1; } } glutPostRedisplay(); } if (key == 'd') { for (int i = 0; i < 12; i++) { if (i == 0 || i % 3 == 0) { square[i] = square[i] + 1; } } glutPostRedisplay(); } if (key == 's') { for (int i = 0; i < 12; i++) { if (i == 1 || i == 7 || i == 10 || i == 4) { square[i] = square[i] - 1; } } glutPostRedisplay(); } if (key == 'a') { for (int i = 0; i < 12; i++) { if (i == 0 || i % 3 == 0) { square[i] = square[i] - 1; } } glutPostRedisplay(); } } I'm sorry if this doesn't quite make sense I'll try to rephrase it in a better way if it doesn't make sense.

    Read the article

  • Using sed with html data

    - by StackedCrooked
    I'm having some problems using sed in combination with html. The following sample illustrates the problem: HTML="<html><body>ENTRY</body><html>" TABLE="<table></table>" echo $HTML | sed -e s/ENTRY/$TABLE/ This outputs: sed: -e expression #1, char 18: unknown option to `s' If I leave out the / from $TABLE so that it becomes <table><table> it works ok. Any ideas on how to fix it?

    Read the article

  • c language:make fgets to keep taking input until I press enter twice?

    - by wello horld
    hi I would like to ask how I would modify this code for the question: (It only accepts one input then prints it out. I want it to keep going until I hit enter (\n) twice. #include <stdio.h> #define MAXLENGTH 1000 int main(void) { char string[MAXLENGTH]; fgets(string, MAXLENGTH, stdin ); printf("%s\n", string); return 0; } I'm confused at the fgets(string, MAXLENGTH, stdin ); line, what does stdin mean/do?

    Read the article

  • debug assertion fail

    - by Kolt
    I have a program that runs correctly if I start it manually. However, if I try to add a registry key to start it automatically during startup, I get this error: Debug assertion failed (str!=null) fprintf.c line:55 I tried to add Sleep(20000) before anything hapens, but same error. here`s the code: main() { FILE* filetowrite; filetowrite = fopen("textfile.txt", "a+"); writefunction(filetowrite); } int writefunction(FILE* filetowrite) { fprintf(filetowrite, "%s", "\n\n"); ... } I also tried with passing filename as char* and opening it in wrtiefunction(), but same error.

    Read the article

  • huge C file debugging problem

    - by valdo
    Hello all. I have a source file in my project, which has more than 65,536 code lines (112,444 to be exact). I'm using an "sqlite amalgamation", which comes in a single huge source file. I'm using MSVC 2005. The problems arrives during debugging. Everything compiles and links ok. But then when I'm trying to step into a function with the debugger - it shows an incorrect code line. What's interesting is that the difference between the correct line number and the one the debugger shows is exactly 65536. This makes me suspect (almost be sure in) some unsigned short overflow. I also suspect that it's not a bug in the MSVC itself. Perhaps it's the limitation of the debug information format. That is, the debug information format used by MSVC stores the line numbers as 2-byte shorts. Is there anything can be done about this (apart from cutting the huge file into several smaller ones) ?

    Read the article

  • [VC++ 2010] Stack around the variable 'xyz' was corrupted.

    - by tirolerhut
    hi, I'm trying to get some simple piece of code I found on a website to work in VC++ 2010 on windows vista 64: #include "stdafx.h" #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { DWORD dResult; BOOL result; char oldWallPaper[MAX_PATH]; result = SystemParametersInfo(SPI_GETDESKWALLPAPER, sizeof(oldWallPaper)-1, oldWallPaper, 0); fprintf(stderr, "Current desktop background is %s\n", oldWallPaper); return 0; } it does compile, but when I run it, I always get this error: Run-Time Check Failure #2 - Stack around the variable 'oldWallPaper' was corrupted. I'm not sure what is going wrong, but I noticed, that the value of oldWallPaper looks something like "C\0\:\0\0U\0s\0e\0r\0s[...]" -- I'm wondering where all the \0s come from. A friend of mine compiled it on windows xp 32 (also VC++ 2010) and is able to run it without problems any clues/hints/opinions? thanks

    Read the article

  • C++ - Implementing my own stream

    - by HardCoder1986
    Hello! My problem can be described the following way: I have some data which actually is an array and could be represented as char* data with some size I also have some legacy code (function) that takes some abstract std::istream object as a param and uses that stream to retrieve data to operate. So, my question is the following - what would be the easy way to map my data to some std::istream object so that I can pass it to my function? I thought about creating a std::stringstream object from my data, but that means copying and (as I assume) isn't the best solution. Any ideas how this could be done so that my std::istream operates on the data directly? Thank you.

    Read the article

  • How to scramble string C#?

    - by a_Elnajjar
    I write the code to scramble word I am create simple game jumble string jumble = theWord; int length = jumble.Count(); for (int i = 0; i < length; ++i) { int index1 = (rand.Next() % length); int index2 = (rand.Next() % length); char temp =jumble[index1]; jumble = jumble.Replace(jumble[index1], jumble[index2]); jumble = jumble.Replace(jumble[index1], temp); }

    Read the article

  • The difference between delete and delete [] in C++

    - by Ilya Melamed
    I've written a class that contains two pointers, one is char* color_ and one in vertexesset* vertex_ where vertexesset is a class I created. In the destractor I've written at start delete [] color_; delete [] vertex_; When It came to the destructor it gave me a segmentation fault. Then I changed the destructor to: delete [] color_; delete vertex_; And now it works fine. What is the difference between the two?

    Read the article

  • Windows C++: LPCTSTR vs const TCHAR

    - by mrl33t
    In my application i'm declaring a string variable near the top of my code to define the name of my window class which I use in my calls to RegisterClassEx, CreateWindowEx etc.. Now, I know that an LPCTSTR is a typedef and will eventually follow down to a TCHAR (well a CHAR or WCHAR depending on whether UNICODE is defined), but I was wondering whether it would be better to use this: static LPCTSTR szWindowClass = TEXT("MyApp"); Or this: static const TCHAR szWindowClass[] = TEXT("MyApp"); I personally prefer the use of the LPCTSTR as coming from a JavaScript, PHP, C# background I never really considered declaring a string as an array of chars. But are there actually any advantages of using one over the other, or does it in fact not even make a difference as to which one I choose? Thank you, in advanced, for your answers.

    Read the article

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