Jsvar to Unsigned char * conversion ..

Posted on
  • Hi i am trying this code

    {
    
    		unsigned char *data,*test;
    		unsigned char ch;
    		JsVar *str = jsvAsString(var, false);	
    		data=test;
    		JsvStringIterator it;
    		jsvStringIteratorNew(&it, str, 0);	 
    		while (jsvStringIteratorHasChar(&it)) 
    		{
    			ch = (unsigned char)jsvStringIteratorGetChar(&it);
    			jsiConsolePrintf("\r\n ch: %c",ch);
    			*test++=ch;
    			jsvStringIteratorNext(&it);
    	    }
    	    jsvStringIteratorFree(&it);
    	    jsvUnLock(str);
    }
    

    but it is not working...
    any suggestions please...

    Thanks
    Vishnu

  • You're not initialising 'test' to anything and you're not zero terminating the string...

    I think jsvGetString does exactly what you want though?

  • hi,
    its working just i removed test and declared 'ch' as array....

    Thanks

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Jsvar to Unsigned char * conversion ..

Posted by Avatar for Vishnu @Vishnu

Actions