Search Results

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

Page 109/245 | < Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >

  • Internal class and access to external members.

    - by Knowing me knowing you
    I have question with this same title here but now as I'll present in code below this seems to behave in the opposite way to the way explained to me in my first question with the same title. Ok code: class LINT_rep { private: char* my_data_; //stores separately every single digit from a number public: class Iterator:public iterator<bidirectional_operator_tag,char*> { Iterator(const LINT_rep&); }; }; #include "StdAfx.h" #include "LINT_rep.h" LINT_rep::Iterator::Iterator(const LINT_rep& owner):myData_(nullptr) { myData_ = owner.my_data_; /* HERE I'M ACCESSING my_data WHICH IS PRIVATE AND THIS CODE COMPILES ON VS2010 ULTIMATE BUT IT SHOULDN'T BECAUSE my_data IS PRIVATE AND OTHER CLASS SHOULDN'T HAVE ACCESS TO IT'S PRIVATE MEMB. AS EXPLAINED TO ME IN QUESTION TO WHICH I;VE PROVIDED LINK. */ } Question in the code. Thanks.

    Read the article

  • delete & new in c++

    - by singh
    Hi This may be very simple question,But please help me. i wanted to know what exactly happens when i call new & delete , For example in below code char * ptr=new char [10]; delete [] ptr; call to new returns me memory address. Does it allocate exact 10 bytes on heap, Where information about size is stored.When i call delete on same pointer,i see in debugger that there are a lot of byte get changed before and after the 10 Bytes. Is there any header for each new which contain information about number of byte allocated by new. Thanks a lot

    Read the article

  • Why this works (Templates, SFINAE). C++

    - by atch
    Hi guys, reffering to yesterday's post, this woke me up this morning. Why this actually works? As long as the fnc test is concerned this fnc has no body so how can perform anything? Why and how this works? I'm REALLY interested to see your answers. template<typename T> class IsClassT { private: typedef char One; typedef struct { char a[2]; } Two; template<typename C> static One test(int C::*); //NO BODY HERE template<typename C> static Two test(…); //NOR HERE public: enum { Yes = sizeof(IsClassT<T>::test<T>(0)) == 1 }; enum { No = !Yes }; }; Thanks in advance with help to understand this very interesting fenomena.

    Read the article

  • What am I encrypting wrong here?

    - by Katie Krueger
    So I have a wordplay project to do and I have to encrypt some characters. I am at the point where I am stuck, and when I run it and type 1 for encrypt it doesn't shift that many letters. It just prints the work over again. I am wondering what I could do to fix it where if I say "hello" it will print 1 character over and say "ifmmp" Thank you! import java.util.Scanner; public class WordPlayTester{ public static void main(String [] args){ String word, reverse=""; String original; int key= 0; String Menu= "1-Encrypt \n2-Decrypt \n3-Is Palindrome \n0-Quit \n-Select an option-"; Scanner in = new Scanner(System.in); System.out.println("-Type any word-"); word = in.nextLine(); System.out.println(Menu); int choice=in.nextInt(); if(choice==1) { System.out.println("Insert a Key number"); int select= in.nextInt(); for (int i=0; i < word.length(); i++) { char c = word.charAt(i); if (c >= 'A' && c <= 'Z') { c = (char)(c - 64); int n = c+1; n = n % 26; if (n < 0) { n = n + 26; } c = (char)(n + 65); } System.out.println(c); } } else if(choice==3) { int length = word.length(); for ( int i = length - 1 ; i >= 0 ; i-- ) reverse = reverse + word.charAt(i); if (word.equals(reverse)) System.out.println("Your word is a palindrome."); else System.out.println("Your word is not a palindrome."); } else if(choice==0) { System.exit(0); } else { System.out.println(Menu); } } }

    Read the article

  • recv receiving not whole data sometime

    - by milo
    hi all, i have following issue: here is the chunk of code: void get_all_buf(int sock, std::string & inStr) { int n = 1; char c; char temp[1024*1024]; bzero(temp, sizeof(temp)); n = recv(sock, temp, sizeof(temp), 0); inStr = temp; }; but sometimes recv returning not whole data (data length always less then sizeof(temp)), only it's part. write side always sends me whole data (i got it with sniffer). what matter? thx. P.S. i know, good manner suggests me to check n (if (n < 0) perror ("error while receiving data), but it doesn't matter now - it's not reason of my problem. P.S.2 i've forgot - it's blocking socket.

    Read the article

  • Magick++ in VS2010 - unresolved external symbol

    - by FlashFan
    Hey guys! I'm trying to use ImageMagick Magick++ for a C++ Project in VS2010. I installed the Library from here: klick Then in my Project, I added c:/program files/ImageMagick-6.6.6-Q16/include to the include folders. Then I tried to use Magick++ with this code: #include <Magick++.h> void main(int argc, char ** argv){ InitializeMagick(*argv); } But this does not work! VS2010 returns the following errors: error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl Magick::InitializeMagick(char const *)" (__imp_?InitializeMagick@Magick@@YAXPBD@Z) error LNK1120: 1 unresolved externals What am I doing wrong? Thanks very much for your help!

    Read the article

  • C++: Define simple string?

    - by Jason
    This thing is really wracking my mind. I'm learning C++ and I wanted to define a constant that I can use in another function, A short answer on how to do this will be fine.. Lets say at the beginning of my code I want to define this constant: //After #includes bool OS = 1; //1 = linux if (OS) { const ??? = "clear"; } else { const ??? = "cls"; } I don't know what type to use to define the "clear" string... I'm so confused. Later on I want to use it within a function: int foo() { system(::cls); //:: for global return 0; } How would I define the string up top, and use the string down below? I heard char only had one character and things... I'm not sure how to use , since it says it's converting string into const char or something.

    Read the article

  • Cocoa multhithreads, locks don't work

    - by Igor
    I have a threadMethod which shows in console robotMotorsStatus every 0.5 sec. But when I try to change robotMotorsStatus in changeRobotStatus method I receive an exception. Where I need to put locks in that program. #import "AppController.h" @implementation AppController extern char *robotMotorsStatus; - (IBAction)runThread:(id)sender { [self performSelectorInBackground:@selector(threadMethod) withObject:nil]; } - (void)threadMethod { char string_to_send[]="QFF001100\r"; //String prepared to the port sending (first inintialization) string_to_send[7] = robotMotorsStatus[0]; string_to_send[8] = robotMotorsStatus[1]; while(1){ [theLock lock]; usleep(500000); NSLog (@"Robot status %s", robotMotorsStatus); [theLock unlock]; } } - (IBAction)changeRobotStatus:(id)sender { robotMotorsStatus[0]='1'; }

    Read the article

  • Same loop giving different output. Java IO

    - by Nitesh Panchal
    Hi, I am facing a very strange problem where the same loop keeps giving me different different output on change of value of BUFFER final int BUFFER = 100; char[] charArr = new char[BUFFER]; StringBuffer objStringBuffer = new StringBuffer(); while (objBufferedReader.read(charArr, 0,BUFFER) != -1) { objStringBuffer.append(charArr); } objFileWriter.write(objStringBuffer.toString()); When i change BUFFER size to 500 it gives me a file of 7 kb when i change BUFFER size to 100000 it gives a file of 400 kb where the contents are repeated again and again. Please help. What should i do to prevent this?

    Read the article

  • Error message in XSLT with C# extension function

    - by iHeartGreek
    Hi! I am received the following error while trying to implement a C# extension function in XSLT. Extension function parameters or return values which have CLR type 'Char[]' are not supported.** code: <xsl:variable name="stringList"> <xsl:value-of select="extension:GetList('AAA BBB CCC', ' ')"/> </xsl:variable> <msxsl:script language="C#" implements-prefix="extension"> <![CDATA[ public string[] GetList(string str, char[] delimiter) { ... ... return str.Split(delimiter, StringSplitOptions.None); } ]]> </msxsl:script> Can someone explain this error message and how to get past it? Thanks!

    Read the article

  • Why do I get corrupt output on my file?

    - by Martin
    I have a simple program which I have compiled in both MinGW and Visual C++ 2008 Express, and both give an output file larger than 88200. When I set s = 0, both programs work as expected. What am I doing wrong? #include <fstream> using namespace std; int main(int argc, char *argv[]) { int i; short s; fstream f; f.open("test.raw", ios_base::out); for(i = 0; i < 44100; i++) { s = i & 0xFFFF; // PROBLEM? f.write(reinterpret_cast<const char *>(&s), sizeof(s)); } f.close(); return 0; }

    Read the article

  • reading a line, tokenizing and assigning to struct in C

    - by Dervin Thunk
    line is fgets'd, and running in a while loop with counter n, d is a struct with 2 char arrays, p and q. Basically, in a few words, I want to read a line, separate it into 2 strings, one up until the first space, and the rest of the line. I clean up afterwards (\n from the file becomes \'0'). The code works, but is there a more idiomatic way to do this? What errors am I running into "unknowingly"? int spc = strcspn(line," "); strncpy(d[n].p, line, spc); d[n].p[spc+1]='\0'; int l = strlen(line)-spc; strncpy(d[n].q, line+spc+1, l); char* nl = strchr(d[n].q, '\n'); if(nl){ *nl='\0'; } n++; Thanks.

    Read the article

  • Can someone explain how pointer to pointer works?

    - by user3549560
    I don't really understand how the pointer to pointer works. Any way to do the same work without using pointer to pointer? struct customer{ char name[20]; char surname[20]; int code; float money; }; typedef struct customer customer; void inserts(customer **tmp) { *tmp = (customer*)malloc(sizeof(customer)); puts("Give me a customer name, surname code and money"); scanf("%s %s %d %f", (*tmp)->name, (*tmp)->surname, &(*tmp)->code,&(*tmp)->money); }

    Read the article

  • Output unicode strings in Windows console app

    - by Andrew
    Hi I was trying to output unicode string to a console with iostreams and failed. I found this: Using unicode font in c++ console app and this snippet works. SetConsoleOutputCP(CP_UTF8); wchar_t s[] = L"èéøÞ???Sæca"; int bufferSize = WideCharToMultiByte(CP_UTF8, 0, s, -1, NULL, 0, NULL, NULL); char* m = new char[bufferSize]; WideCharToMultiByte(CP_UTF8, 0, s, -1, m, bufferSize, NULL, NULL); wprintf(L"%S", m); However, I did not find any way to output unicode correctly with iostreams. Any suggestions?

    Read the article

  • Write to a binary file?

    - by rick irby
    Here is data structure w/ variables: struct Part_record { char id_no[3]; int qoh; string desc; double price: }; --- (Using "cin" to input data) --- Part_record null_part = {" ", 0," ",0.0}; --- --- file.seekg( -(long)sizeof(Part_record), ios::cur); file.write( ( char *)&part, sizeof(Part_record) ); The three variables, qoh, Id_no & price, write out correctly, but the "desc" variable is not right. Do I need to initialize Part_record some other way? It should be 20 characters in length. If you have enough info here, pls share your advice,thanks.

    Read the article

  • Store address dynamic array in c

    - by user280642
    I'm trying to save the address of a dynamic array index. struct sstor *dlist; struct node *q; q->item = &(dlist->item[(dlist->sz)-1]); // Problem? This is my node struct node { char **item; struct node *next; struct node *prev; }; This is my array struct sstor { int sz; int maxsz; char item[][1024]; }; I'm still new to pointers. The line below gives the error: assignment from incompatible pointer type q->item = &(dlist->item[(dlist->sz)-1]);

    Read the article

  • passin structure form VC++ to C#

    - by Anu
    Hi, im using C# dll in VC++ application.I have somedetails in VC++ like PageNumer pageTitle PageDesc BoxDetail I have to pass this to C# Dll. So i made one structure in VC++,then i pas that to C#.But i could't do that.Pls help mw. VC++ Function: struct SCS3OverVwPg { __int32 iOvrPgNo; char sOvrPgTitle[30]; //OverView Page Title }; void CToolTab::SendOverview() { SCS3OverVwPg *pOverVw = 0; pOverVw = new SCS3OverVwPg; Globals1::gwtoolbar->SetTree(pOverVw); } C# function: public struct SCS3Over { Int32 iOvrPgNo; char[] sOvrPgTitle; } public void SetTree(SCS3Over x) { MessageBox.Show("Data received"); } If i do like this,it shows error error C2664: 'Tabcontrol::ToolBar::SetTree' : cannot convert parameter 1 from 'SCS3OverVwPg *' to 'SCS3Over' IF i change name in C# dll to SCS3OverwPg, it show error of structure redifinition Pls help me.

    Read the article

  • [c]how to take input for a character pionter without using fget?

    - by ashish yadav
    consider the code include int main() {char* a; scanf("%s",a);//&a and &a[0] give same results-crashes printf("%s",); return 0; } why does this code results in crashing?whereas this code using character array works fine? include int main() {char a[100]; scanf("%s",&a[0]);//works fine printf("%s",a); return 0; } the difference being character array and pointer?but i knew that pointer just points to the first element that is &a[0] should work fine but upper code crashes for all three that is a,&a and &a[0]? the main thing i would to gather is how can i take input of a character pointer if i insist on using scanf only? i apologize if i am not clear. thanks in advance:)

    Read the article

  • Is it good practice to initialize array in C/C++?

    - by sand
    I recently encountered a case where I need to compare two files (golden and expected) for verification of test results and even though the data written to both the files were same, the files does not match. On further investigation, I found that there is a structure which contains some integers and a char array of 64 bytes, and not all the bytes of char array were getting used in most of the cases and unused fields from the array contain random data and that was causing the mismatch. This brought me ask the question whether it is good practice to initialize the array in C/C++ as well, as it is done in Java?

    Read the article

  • jQuery $.post & $.append & IE6

    - by Jim
    I'm having a weird problem with jQuery and IE6. Script works on IE7+ and with all other browsers I have tried it. I can't post the full script, but what it does is this: $.post("file.php",{'foo':'bar'},function(data){ $('#target').append(data) }) When I run the code in IE6, #target just shows ? and a white char with a hole in the middle. I have no idea what this second char is. My initial thought was that this was some sort of content-type problem because the file.php just echoes answer without any header information. I added Content-type: text/html with header() but didn't help. Any suggestions?

    Read the article

  • Dynamic allocated array is not freed

    - by Stefano
    I'm using the code above to dynamically allocate an array, do some work inside the function, return an element of the array and free the memory outside of the function. But when I try to deallocate the array it doesn't free the memory and I have a memory leak. The debugger pointed to the myArray variable shows me the error CXX0030. Why? struct MYSTRUCT { char *myvariable1; int myvariable2; char *myvariable2; .... }; void MyClass::MyFunction1() { MYSTRUCT *myArray= NULL; MYSTRUCT *myElement = this->MyFunction2(myArray); ... delete [] myArray; } MYSTRUCT* MyClass::MyFunction2(MYSTRUCT *array) { array = (MYSTRUCT*)operator new(bytesLength); ... return array[X]; }

    Read the article

  • C++ Beginner - Best way to read 3 consecutive values from the command line?

    - by Francisco P.
    Hello everyone, I am writing a text-based Scrabble implementation for a college project. The specification states that the user's position input must be read from single line, like this: Coordinates of the word's first letter and orientation (<A – P> <1 – 15> <H ou V>): G 5 H G 5 H is the user's input for that particular example. The order, as shown, must be char int char. What is the best way to read the user's input? cin >> row >> column >> orientation will cause crashes if the user screws up. A getline and a subsequent string parser are a valid solution, but represent a bit of work. Is there another, better, way to do this, that I am missing? Thanks for your time!

    Read the article

  • [c++] upload image to imageshack

    - by cinek1lol
    Hi. I would like to send pictures via a program written in C + + I wrote such a thing using curl.exe WinExec("C:\\curl\\curl.exe -H Expect: -F \"fileupload=@C:\\curl\\ok.jpg\" -F \"xml=yes\" -# \"http://www.imageshack.us/index.php\" -o data.txt -A \"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\" -e \"http://www.imageshack.us\"", NULL); This only works that I would like to send pictures to a variable pre-loaded char (you know what I mean? first reads the pictures into a variable and then send that variable), because now I have to specify the path to the images on disk I wanted to make this program was written in C + + using the curl library, and not the exe. I found it such a program (which some have modified) #include <stdio.h> #include <string.h> #include <iostream> #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> int main(int argc, char *argv[]) { CURL *curl; CURLcode res; struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; struct curl_slist *headerlist=NULL; static const char buf[] = "Expect:"; curl_global_init(CURL_GLOBAL_ALL); /* Fill in the file upload field */ curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "send", CURLFORM_FILE, "nowy.jpg", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "nowy.jpg", CURLFORM_COPYCONTENTS, "nowy.jpg", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "send", CURLFORM_END); curl = curl_easy_init(); headerlist = curl_slist_append(headerlist, buf); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://www.imageshack.us/index.php"); if ( (argc == 2) && (!strcmp(argv[1], "xml=yes")) ) curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); res = curl_easy_perform(curl); curl_easy_cleanup(curl); curl_formfree(formpost); curl_slist_free_all (headerlist); } system("pause"); return 0; } I will be grateful for any help

    Read the article

  • Simple doubt related to strings in C (question in an interview)

    - by piemesons
    // The first example: char text[] = "henri"; char *p; p = text; *(p + 1) = 'E'; // Output = hEnri // Now If we want to remove the "e" ie hnri, we would go for????? *(p + 1)=????? Please dont say start copying the array. I am looking for the best solution. Its an interview question... EDIT I specially mentioned the question that i am not asking for the solution like start moving the element. I thought there must be some other good solution..

    Read the article

  • Constructing a function call in C

    - by 0x6adb015
    Given that I have a pointer to a function (provided by dlsym() for example) and a linked list of typed arguments, how can I construct a C function call with those arguments? Example: struct param { enum type { INT32, INT64, STRING, BOOL } type; union { int i32; long long i64; char *str; bool b; } value; struct param *next; }; int call_this(int (*function)(), struct param *args) { int result; /* magic here that calls function(), which has a prototype of f(int, long long, char *, bool); , when args consist of a linked list of INT32, INT64, STRING, BOOL types. */ return result; } The OS is Linux. I would like the solution to be portable across MIPS, PPC and x86 (all 32 bits) architecture, using GCC as the compiler. Thanks!

    Read the article

< Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >