Search Results

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

Page 71/245 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • C related, store a signed long int (32bit) as 4 octets?

    - by Doori Bar
    I managed to get a unsigned long int octets-representation (BE) by reading IPv4 methods, and I managed to read about how signed integers are using the MSB as the sign indicator, which makes 00 00 00 00 to be 0, while 7F FF FF FF is 2147483647. But I can't manage how to do the same for signed long integers? #include <stdio.h> #include <string.h> int main (void) { unsigned long int intu32; unsigned char octets[4]; intu32 = 255; octets[3] = (intu32) & 255; octets[2] = (intu32 >> 8) & 255; octets[1] = (intu32 >> 16) & 255; octets[0] = (intu32 >> 24) & 255; printf("(%d)(%d)(%d)(%d)\n", octets[0], octets[1], octets[2], octets[3]); intu32 = (octets[0] << 24) | (octets[1] << 16) | (octets[2] << 8) | octets[3]; printf("intu32:%lu\n", intu32); return 0; } Thanks in advance, Doori bar

    Read the article

  • 'table' undeclared (first use this in a function)

    - by user2318083
    So I'm not sure why this isn't working, I'm creating a new table and setting it to the variable 'table' Is there something I'm doing wrong? This is the error I get when trying to run it: src/simpleshell.c:19:3: error: ‘table’ undeclared (first use in this function) src/simpleshell.c:19:3: note: each undeclared identifier is reported only once for each function it appears in My code is as follows: #include "parser.h" #include "hash_table.h" #include "variables.h" #include "shell.h" #include <stdio.h> int main(void) { char input[MAXINPUTLINE]; table = Table_create(); signal_c_init(); printf("\nhlsh$ "); while(fgets(input, sizeof(input), stdin)){ stripcrlf(input); parse(input); printf("\nhlsh$ "); } Table_free(table); return 0; } Then this is my create a table in the hash_table file: struct Table *Table_create(void){ struct Table *t; t = (struct Table*)calloc(1, sizeof(struct Table)); return t; } From the hash_table.c: #include "hash_table.h" #include "parser.h" #include "shell.h" #include "variables.h" #include <stdio.h> #include <sys/resource.h> #include <sys/wait.h> #include <sys/types.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pwd.h> #include <fcntl.h> #include <limits.h> #include <signal.h> struct Table *table; unsigned int hash(const char *x){ int i; unsigned int h = 0U; for (i=0; x[i]!='\0'; i++){ h = h * 65599 + (unsigned char)x[i]; } return h % 1024; }

    Read the article

  • Why do I have such high overhead when creating tables in MSSQL7?

    - by scotty2012
    I have an old system running MSSQL7. It takes about 10.5 seconds to create the table below and another 30 seconds to add the index. Is there anything I can do to decrease these times? CREATE TABLE [dbo].[MyTable] ( [queue] [int] NOT NULL , [seqNum] [numeric](12, 0) NOT NULL , [cTime] [char] (14) NOT NULL , [msg] [char] (255) NULL , [status] [int] NOT NULL , [socket] [int] NULL ) ON [PRIMARY] GO CREATE INDEX [search] ON [dbo].[MyTable]([queue], [seqNum], [status]) ON [PRIMARY] GO CREATE INDEX [new] ON [dbo].[MyTable]([queue], [status]) ON [PRIMARY]

    Read the article

  • How to parse the XML file in RapidXML.

    - by user337891
    I have to parse a xml file in C++. I was researching and found rapidxml library for this. I have doubt about "doc.parse<0(xml)" can xml be .xml file or it needs to be a string or char *? If can take only string or char * then I guess I need to read the whole file and store it in a char array and pass the pointer of it to the function? Is there a way to directly use file because I would need to change the xml file inside the code also. If it is not possible in RapidXML then please suggest some other xml libraries in C++. Thanks!!! Ashd

    Read the article

  • RIA Services Filter descriptor

    - by Mohit
    I have a Filterdescriptor as shown below. The propertypath is of type 'char?' I get following InvalidOperationException when I filter by entering a value Y InnerException {System.InvalidOperationException: A FilterDescriptor with its PropertyPath equal to 'Valid' cannot be evaluated. --- System.ArgumentException: Operator 'StartsWith' incompatible with operand types 'Char?' and 'Char?' --- System.ArgumentNullException: Value cannot be null. Parameter name: method at System.Linq.Expressions.Expression.ValidateCallArgs(Expression instance, MethodInfo method, ReadOnlyCollection1& arguments) at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable1 arguments) at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, Expression[] arguments) at System.Windows.Controls.LinqHelper.GenerateMethodCall(String methodName, Expression left, Expression right) at System.Windows.Controls.LinqHelper.GenerateStartsWith(Expression left, Expression right) at System.Windows.Controls.LinqHelper.BuildFilterExpression(Expression propertyExpression, FilterOperator filterOperator, Expression valueExpression, Boolean isCaseSensitive, Expression& filterExpression) --- End of inner exception stack trace --- --- End of inner exception stack trace ---} System.Exception {System.InvalidOperationException}

    Read the article

  • Extracting, then passing raw data into another class - How to avoid copying twice while maintaining

    - by Kache4
    Consider a class Book with a stl container of class Page. each Page holds a screenshot, like page10.jpg in raw vector<char> form. A Book is opened with a path to a zip, rar, or directory containing these screenshots, and uses respective methods of extracting the raw data, like ifstream inFile.read(buffer, size);, or unzReadCurrentFile(zipFile, buffer, size). It then calls the Page(const char* stream, int filesize) constructor. Right now, it's clear that the raw data is being copied twice. Once to extract to Book's local buffer and a second time in the Page ctor to the Page::vector<char>. Is there a way to maintain encapsulation while getting rid of the middleman buffer?

    Read the article

  • How to read STDIN into string variable until EOF in C?

    - by NovumCoder
    Hi, im getting "Bus Error" trying to read stdin into a char* variable. I just want to read whole stuff coming over stdin and put it first into a variable, then continue working on the variable. My Code is as follows: char* content; char* c; while( scanf( "%c", c)) { strcat( content, c); } fprintf( stdout, "Size: %d", strlen( content)); But somehow i always get "Bus error" returned by calling "cat test.txt | myapp", where "myapp" is the compiled code above. My question is how do i read stdin until EOF into a variable? As you see in the code, i just want to print the size of input coming over stdin, in this case it should be equal to the size of the file "test.txt". I thought just using scanf would be enough, maybe buffered way to read stdin?

    Read the article

  • Cannot call SAPI from dll

    - by Quandary
    Question: The below code works fine as long as it is in an executable. It uses the msft (text-to-)speech API (SAPI). But as soon as I put it in a dll and load it with loadlibrary from an executable, it doesn't work. I've also tried to change CoInitialize(NULL); to CoInitializeEx(NULL,COINIT_MULTITHREADED); and I tried with all possible flags ( COINIT_APARTMENTTHREADED, COINIT_MULTITHREADED, COINIT_DISABLE_OLE1DDE, COINIT_SPEED_OVER_MEMORY) But it's always stuck at hr = CoCreateInstance(__uuidof(SpVoice), NULL, CLSCTX_INPROC_SERVER, IID_ISpVoice, (void **) &pVoice); I also tried those flags here: CLSCTX_INPROC_SERVER,CLSCTX_SERVER, CLSCTX_ALL, but nothing seems to help... There are no errors, it doesn't crash, it just sleeps forever at CoCreateInstance... This is the code as single exe (working) #include <windows.h> #include <sapi.h> #include <iostream> #include <cstdlib> int main(int argc, char* argv[]) { ISpVoice * pVoice = NULL; //CoInitializeEx(NULL,COINIT_MULTITHREADED); HRESULT hr = CoInitialize(NULL); if( FAILED(hr) ) { MessageBox(NULL, TEXT("Failed To Initialize"), TEXT("Error"),0); printf("Failed!\n"); char buffer[2000] ; sprintf(buffer, "An error occured: 0x%08X.\n", hr); FILE * pFile = fopen ( "c:\\temp\\CoInitialize_exe.txt" , "w" ); fwrite (buffer , 1 , sizeof(buffer) , pFile ); fclose (pFile); } else { //CoGetClassObject(CLSID_SpVoice, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory, (void**) &pClsF); //hr = CoGetClassObject(CLSID_SpVoice, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory, (void**) &pClsF); hr = CoCreateInstance(__uuidof(SpVoice), NULL, CLSCTX_INPROC_SERVER, IID_ISpVoice, (void **) &pVoice); //HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **) &pVoice); if( SUCCEEDED( hr ) ) { hr = pVoice->Speak(L"Test Test", 0, NULL); hr = pVoice->Speak(L"This sounds normal <pitch middle = '-10'/> but the pitch drops half way through", SPF_IS_XML, NULL ); pVoice->Release(); pVoice = NULL; } else { MessageBox(NULL, TEXT("Failed To Create a COM instance..."), TEXT("Error"),0); char buffer[2000] ; sprintf(buffer, "An error occured: 0x%08X.\n", hr); FILE * pFile = fopen ( "c:\\temp\\CoCreateInstance_exe.txt" , "w" ); fwrite (buffer , 1 , sizeof(buffer) , pFile ); fclose (pFile); } } CoUninitialize(); return EXIT_SUCCESS; } This is the exe loading the dll (stays forever at printf("trying to create instance.\n"); ) #include <windows.h> #include <sapi.h> #include <iostream> #include <cstdlib> int main(int argc, char* argv[]) { // C:\Windows\System32\Speech\Common\sapi.dll //LoadLibraryA("sapi.dll"); LoadLibraryA("Sapidll2.dll"); return EXIT_SUCCESS; // Frankly, that would be nice... } And this is Sapidll2.dll // dllmain.cpp : Defines the entry point for the DLL application. #include "stdafx.h" #include <iostream> #include <cstdlib> #include <string> #include <windows.h> #include <sapi.h> int init_engine() { ISpVoice * pVoice = NULL; //HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); HRESULT hr = CoInitialize(NULL); if(FAILED(hr) ) { MessageBox(NULL, TEXT("Failed To Initialize"), TEXT("Error"), 0); char buffer[2000] ; sprintf(buffer, "An error occured: 0x%08X.\n", hr); FILE * pFile = fopen ( "c:\\temp\\CoInitialize_dll.txt" , "w" ); fwrite (buffer , 1 , strlen(buffer) , pFile ); fclose (pFile); } else { printf("trying to create instance.\n"); //HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **) &pVoice); //hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **) &pVoice); //HRESULT hr = CoCreateInstance(__uuidof(ISpVoice), NULL, CLSCTX_INPROC_SERVER, IID_ISpVoice, (void **) &pVoice); HRESULT hr = CoCreateInstance(__uuidof(SpVoice), NULL, CLSCTX_ALL, IID_ISpVoice, (void **) &pVoice); if( SUCCEEDED( hr ) ) { printf("Succeeded\n"); //hr = pVoice->Speak(L"The text to speech engine has been successfully initialized.", 0, NULL); } else { printf("failed\n"); MessageBox(NULL, TEXT("Failed To Create COM instance"), TEXT("Error"), 0); char buffer[2000] ; sprintf(buffer, "An error occured: 0x%08X.\n", hr); FILE * pFile = fopen ( "c:\\temp\\CoCreateInstance_dll.txt" , "w" ); fwrite (buffer , 1 , strlen(buffer) , pFile ); fclose (pFile); } } if(pVoice != NULL) { pVoice->Release(); pVoice = NULL; } CoUninitialize(); return true ; } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: init_engine(); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }

    Read the article

  • WPF DataGridTextColumn Can't type point for float data

    - by Alvin
    I had a WPF DataGrid and use DataGridTextColumn Binding to a Collection. The items in Collection had some float property. When my program launched, I modify the value of float property in DataGrid, if I type a integer value, it works well. But if I type char . for a float value, char . can't be typed. I had to type all the numbers first, and then jump to the . position to type char . to finish my input. So how can I type . in my situation? Thanks.

    Read the article

  • cannot convert from 'cli::array<Type> ^' to 'cli::array<Type> ^[]'

    - by user1576628
    I'm pretty new to C++/CLI and I am trying to convert a System::String to a System::Char array. Here's what I have so far: private: System::Void modeToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { Mode frmMode; if(frmMode.ShowDialog() == System::Windows::Forms::DialogResult::OK){ array <Char>^ load [] = gcnew array<Char>(txtbxName->Text->ToCharArray()); } } txtbxName is a textbox inside a the form. Supposedly, this should work, but I get the compiler error: error C2440: cannot convert from 'cli::array<Type> ^' to 'cli::array<Type> ^[]' for the fourth line of the snippet.

    Read the article

  • strcpy v/s memcpy

    - by Sachin Chourasiya
    What is the difference between memcpy() and strcpy()? I tried to find it with the help of a program but both are giving the same output. int main() { char s[5]={'s','a','\0','c','h'}; char p[5]; char t[5]; strcpy(p,s); memcpy(t,s,5); printf("sachin p is [%s], t is [%s]",p,t); return 0; } Output sachin p is [sa], t is [sa]

    Read the article

  • JNA and ZBar(library for bar code reader)

    - by user219120
    I'm creating Java Interface with JNA for ZBar(library for bar code reader). In JNA, structures in C are needed to declare. For example:: // In C typedef struct { char* id; char* name; int age; char* sectionId } EMPLOYEE; to // In Java with JNA public static class Employee extends Structure { // com.sun.jna.Structure String id; String name; int age; String sectionId; } But in ZBar, structures have no members. For example:: // zbar-0.10/include/zbar.h // line:1009-1011 struct zbar_image_scanner_s; /** opaque image scanner object. */ typedef struct zbar_image_scanner_s zbar_image_scanner_t; That doesn't declare size or members of the structures. How can I write interfaces for these structures in JNA?

    Read the article

  • database datatype size

    - by yeeen
    Just to clarify by specifying sth like VARCHAR(45) means it can take up to max 45 characters? I rmb I heard from someone a few years ago that the number in the parathesis doesn't refer to the no of characters, then the person tried to explain to me sth quite complicated which i don't understand n forgot alr. And what is the difference btn CHAR and VARCHAR? I did search ard a bit and see that CHAR gives u the max of the size of the column and it is better to use it if ur data has a fix size and use VARCHAR if ur data size varies. But if it gives u the max of the size of the column of all the data of this col, isn't it better to use it when ur data size varies? Esp if u don't know how big is ur data size gg to be. VARCHAR needs to specify the size (CHAR don't really need right?), isn't it more troublesome?

    Read the article

  • algorithm diagram

    - by tunl
    This is the max searching algorithm diagram: So, I wonder how can draw diagram for Recursion in HaNoi Tower program: package tunl; public class TowersApp { static int n = 3; public static void main(String[] args) { TowersApp.doTowers(3, 'A', 'B', 'C'); } public static void doTowers(int n, char from, char inter, char to) { if (n == 1) { System.out.println("disk 1 from "+ from + " to " + to); } else { doTowers(n-1, from, to, inter); System.out.println("disk " + n + " from " + from + " to " + to); doTowers(n-1, inter, from, to); } } } I can't draw it. Anyone can help me !!!

    Read the article

  • PHP, MySQL, and temporary tables

    - by dave
    Php novice. 1.Is there anything wrong with this PHP & MySQL code? include_once "db_login.php" ; $sql = "DROP TEMPORARY TABLE IF EXISTS temp_sap_id_select" ; mysql_query ( $sql ) or ( "Error " . mysql_error () ) ; $sql = " CREATE TEMPORARY TABLE temp_sap_id_select ( `current_page` INT NOT NULL, `total_pages` INT NOT NULL, `select_date` DATE NOT NULL, `select_schcode` CHAR(6) NOT NULL, `select_user` CHAR(30) NOT NULL, `select_id` CHAR(9) NOT NULL ) " ; mysql_query ( $sql ) or ( "Error " . mysql_error () ) ; 2.Admittedly, I'm a dull boy, but I'll ask anyway: If I'm using a MySQL GUI and have open the target database, will it be aware of the above temporary table created by PHP/MySQL (IF the temporary table is properly created)?

    Read the article

  • Using boost::iostreams to parse a binary file byte by byte

    - by Zsol
    So I would like to parse a binary file and extract some data from it. The problem I am facing with this is that I need to convert a stream of chars to a stream of unsigned chars. Reading the boost documentation, it seems that boost::iostreams::code_converter should be the solution for this, so I tried this: typedef unsigned char uint8_t; typedef boost::iostreams::stream<boost::iostreams::code_converter< boost::iostreams::basic_array_source<uint8_t> >, std::codecvt<uint8_t, char, std::mbstate_t> > array_stream; The idea was to specify a codecvt with InternalType=uint8_t and ExternalType=char. Unfortunately this does not compile. So the question is: how do I convert a stream of chars to a stream of uint8_ts?

    Read the article

  • How to use variables with regex?

    - by dontoo
    This is the input string: 23x^45*y or 2x^2 or y^4*x^3. I am matching ^[0-9]+ after letter x. In other words I am matching x followed by ^ followed by numbers. Problem is that I don't know that I am matching x, it could be any letter that I stored as variable in my char array. For example: foreach (char cEle in myarray) // cEle is letter in char array x, y, z, ... { match CEle in regex(input) //PSEUDOCODE } I am new to regex and I new that this can be done if I define regex variables, but I don't know how.

    Read the article

  • Using fscanf with dynamically allocated buffer.

    - by ryyst
    Hi, I got the following code: char buffer[2047]; int charsRead; do { if(fscanf(file, "%2047[^\n]%n%*c", buffer, &charsRead) == 1) { // Do something } } while (charsRead == 2047); I wanted to convert this code to use dynamically allocated variables so that when calling this code often I won't get heavy memory leakage. Thus, I tried this: char *buffer = malloc(sizeof(char) * 2047); int *charsRead = malloc(sizeof(int)); do { if(fscanf(file, "%2047[^\n]%n%*c", *buffer, charsRead) == 1) { // Do something } } while (*charsRead == 2047); Unfortunately, this does not work. I always get “EXC_BAD_ACCESS” errors, just before the if-statement with the fscanf call. What am I doing wrong? Thanks for any help! -- Ry

    Read the article

  • Adding a JPanel to another JPanel having TableLayout

    - by user253530
    I am trying to develop a map editor in java. My map window receives as a constructor a Map object. From that map object i am able to retrieve the Grid and every item in the grid along with other getters and setters. The problem is that even though the Mapping extends JComponent, when I place it in a panel it is not painted. I have overridden the paint method to satisfy my needs. Here is the code, maybe you could help me. public class MapTest extends JFrame implements ActionListener { private JPanel mainPanel; private JPanel mapPanel; private JPanel minimapPanel; private JPanel relationPanel; private TableLayout tableLayout; private JPanel tile; MapTest(Map map) { mainPanel = (JPanel) getContentPane(); mapPanel = new JPanel(); populateMapPanel(map); mainPanel.add(mapPanel); this.setPreferredSize(new Dimension(800, 600)); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } private double[][] generateTableLayoutSize(int x, int y, int size) { double panelSize[][] = new double[x][y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { panelSize[i][j] = size; } } return panelSize; } private void populateMapPanel(Map map) { double[][] layoutSize = generateTableLayoutSize(map.getMapGrid().getRows(), map.getMapGrid().getColumns(), 50); tableLayout = new TableLayout(layoutSize); for(int i = 0; i < map.getMapGrid().getRows(); i++) { for(int j = 0; j < map.getMapGrid().getColumns(); j++) { tile = new JPanel(); tile.setName(String.valueOf(((Mapping)map.getMapGrid().getItem(i, j)).getCharacter())); tile.add(map.getMapItem(i, j)); String constraint = i + "," + j; mapPanel.add(tile, constraint); } } mapPanel.validate(); mapPanel.repaint(); } public void actionPerformed(ActionEvent e) { throw new UnsupportedOperationException("Not supported yet."); } } My Mapping Class public class Mapping extends JComponent implements Serializable{ private BufferedImage image; private Character character; //default public Mapping() { super(); this.image = null; this.character = '\u0000'; } //Mapping from image and char public Mapping(BufferedImage image, char character) { super(); this.image = image; this.character = character; } //Mapping from file and char public Mapping(File file, char character) { try { this.image = ImageIO.read(file); this.character = character; } catch (IOException ex) { System.out.println(ex); } } public char getCharacter() { return character; } public void setCharacter(char character) { this.character = character; } public BufferedImage getImage() { return image; } public void setImage(BufferedImage image) { this.image = image; repaint(); } @Override /*Two mappings are consider the same if -they have the same image OR -they have the same character OR -both of the above*/ public boolean equals(Object mapping) { if (this == mapping) { return true; } if (mapping instanceof Mapping) { return true; } //WARNING! equals might not work for images return (this.getImage()).equals(((Mapping) mapping).getImage()) || (this.getCharacter()) == (((Mapping) mapping).getCharacter()); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); //g.drawImage(image, 0, 0, null); g.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), null); } // @Override // public Dimension getPreferredSize() { // if (image == null) { // return new Dimension(10, 10); //instead of 100,100 set any prefered dimentions // } else { // return new Dimension(100, 100);//(image.getWidth(null), image.getHeight(null)); // } // } private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { character = (Character) in.readObject(); image = ImageIO.read(ImageIO.createImageInputStream(in)); } private void writeObject(java.io.ObjectOutputStream out) throws IOException { out.writeObject(character); ImageWriter writer = (ImageWriter) ImageIO.getImageWritersBySuffix("jpg").next(); writer.setOutput(ImageIO.createImageOutputStream(out)); ImageWriteParam param = writer.getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionQuality(0.85f); writer.write(null, new IIOImage(image, null, null), param); } }

    Read the article

  • reading a string with spaces with sscanf

    - by SDLFunTimes
    For a project I'm trying to read an int and a string from a string. The only problem is sscanf appears to break reading an %s when it sees a space. Is there anyway to get around this limitation? Here's an example of what I'm trying to do: #include<stdio.h> #include<stdlib.h> int main(int argc, char** argv) { int age; char* buffer; buffer = malloc(200 * sizeof(char)); sscanf("19 cool kid", "%d %s", &age, buffer); printf("%s is %d years old\n", buffer, age); return 0; } What it prints is: "cool is 19 years old" where I need "cool kid is 19 years old". Does anyone know how to fix this?

    Read the article

  • Last byte missing when casting from varbinary to varchar

    - by xaxie
    I got the last byte losing when converting varbinary to varchar in some case. For example: DECLARE @binary varbinary(8000), @char varchar(8000) set @binary = 0x000082 set @char = CAST(@binary as varchar(8000)) select BinaryLength=DATALENGTH(@binary), CharLength=DATALENGTH(@char) The result is BinaryLength CharLength 3 2 The affected byte value is from 0x81 - 0xFE. The stranger thing is that if I use varchar(MAX) instead varchar(8000) when casting, there is no any problem. Could someone tell me the root cause of the issue? PS: I run the sql in MS SQL server 2008. Thanks!

    Read the article

  • How to access pixels of an NSBitmapImageRep?

    - by Paperflyer
    I have an NSBitmapImageRep that is created like this: NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:waveformSize.width pixelsHigh:waveformSize.height bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:YES colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0]; Now I want to access the pixel data so I get a pointer to the pixel planes using unsigned char *bitmapData; [imageRep getBitmapDataPlanes:&bitmapData]; According to the Documentation this returns a C array of five character pointers. But how can it do that? since the type of the argument is unsigned char **, it can only return an array of chars, but not an array of char pointers. So, this leaves me wondering how to access the individual pixels. Do you have an idea how to do that? (I know there is the method – setColor:atX:y:, but it seems to be pretty slow if invoked for every single pixel of a big bitmap.)

    Read the article

  • A question in java.lang.Integer internal code

    - by Daziplqa
    Hi folks, While looking in the code of the method: Integer.toHexString I found the following code : public static String toHexString(int i) { return toUnsignedString(i, 4); } private static String toUnsignedString(int i, int shift) { char[] buf = new char[32]; int charPos = 32; int radix = 1 << shift; int mask = radix - 1; do { buf[--charPos] = digits[i & mask]; i >>>= shift; } while (i != 0); return new String(buf, charPos, (32 - charPos)); } The question is, in toUnsignedString, why we create a char arr of 32 chars?

    Read the article

  • shared library in C

    - by sasayins
    Hi, I am creating a shared library in C but don't know what is the correct implementation of the source codes. I want to create an API like for example, printHello, int printHello( char * text ); This printHello function will call another function: In source file, libprinthello.c, void printHello( char * text ) { printHi(); printf("%s", text); } Since this printHello function is the interface for the user or application: In header file libprinthello.h, extern void printHello( char * text); Then in the source file of the printHi function, printhi.c void printHi() { printf("Hi\n"); } Then my problem is, since printHello is the only function that I want to expose in the user, what implementation should I do in printHi function?

    Read the article

  • c++ vector.push_back error: request for member 'push_back'..., which is of non-class type 'vector(ch

    - by Ziplin
    I'm using Cygwin with GCC, and ultimately I want to read in a file of characters into a vector of characters, and using this code #include <fstream> #include <vector> #include <stdlib.h> using namespace std; int main (int argc, char *argv[] ) { vector<char> string1(); string1.push_back('a'); return 0; } generates this compile time error: main.cpp: In function int main(int, char**)': main.cpp:46: error: request for memberpush_back' in string1', which is of non -class typestd::vector ()()' I tried this with a vector of ints and strings as well and they had the same problem.

    Read the article

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >