Sponsored Content
Top Forums Programming Unable to assign zero to unsigned character array Post 302757167 by kbw on Thursday 17th of January 2013 06:48:12 AM
Old 01-17-2013
This sets the character zero (not ASCII zero).
Code:
#include <string.h>

struct ABCD
{
    unsigned char abc[6];
    unsigned char def;
    unsigned char ghi;
};

void abc(struct ABCD* s_tag)
{
//  memset(s_tag, '0', sizeof(*s_tag));    // this or the stuff below

    memcpy(s_tag->abc, "000000", sizeof(s_tag->abc));
    s_tag->def = '0';
    s_tag->ghi = '0';
}

int main()
{
    struct ABCD var;

    abc(&var);

    return 0;
}


Last edited by kbw; 01-17-2013 at 07:54 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

assign awk array with printf

I am trying to assign a awk array for further processing later in the script. I can't seem to figure it out. If someone could look at this and help me, I would very much appreciate it. Thanks in Advance. for ( x = 1 ; x <= Var ; x++ ) { if ( x in varr ) { ... (2 Replies)
Discussion started by: timj123
2 Replies

2. Shell Programming and Scripting

Unable to assign value to variable using awk coz of whitespace in value

Unix gurus, I have a file as below, which is basically the result set obtained from a sql query on an Oracle database. ID PROG_NAME USER_PROG_NAME -------- --------------- ---------------------------------------- 33045 INCOIN Import Items 42690 ... (3 Replies)
Discussion started by: sunpraveen
3 Replies

3. Shell Programming and Scripting

How to assign a variable to an array

I want to ask the user to enter an X amount of file names. I want to put those names into an array and then loop back through them to verify they are in the directory. 1st- How would I assign the value to an array and what is the correct syntax. 2nd- how would i reference that array after I... (3 Replies)
Discussion started by: tvb2727
3 Replies

4. Shell Programming and Scripting

assign value to array variable

Hi, I have a piece of code as follows: i=0 while read LINE do var = "$LINE" i=$((i+1)) echo "${var}" done < file I want to assign value to the array var. However, when i execute the script i get a error. Please can you help me know what i am missing. I ultimately want to... (2 Replies)
Discussion started by: sunrexstar
2 Replies

5. Shell Programming and Scripting

Assign value to array separated by #

Hi all , I have a string like para1#para2#para3 i want to assign para1 as first element para2 as second and so on i tried IFS=# set -A array para1#para2#para3 echo ${array} para1 para2 para3 i want echo ${array} para1 (2 Replies)
Discussion started by: max_hammer
2 Replies

6. Shell Programming and Scripting

Unable to assign command output to variable

Code set -x STATUS="0" echo $STATUS for i in `ls -ltr Report*|awk '{ print $9 }'` do if then flg = "`head -1 "$i" |cut -c 31-33`" echo `head -1 "$i" |cut -c 31-33` echo $flg if then echo "having Fun" STATUS="2" else echo "no Fun" fi fi (2 Replies)
Discussion started by: Funkeydude
2 Replies

7. Shell Programming and Scripting

Unable to read assign values to two variables in while loop

I am trying to read a input file which has two columns separated by space Input file server1 server2 server3 server4 server5 server6 When i execute the below while code it reads line by line and a and b variables are able to successfully fetch the values while read a b do echo "$a" echo... (5 Replies)
Discussion started by: chidori
5 Replies

8. Shell Programming and Scripting

How to Assign an shell array to awk array?

Hello All, Can you please help me with the below. #!/bin/bash ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1" ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies

9. Shell Programming and Scripting

Unable to assign a value

I have written a shell script to calculate dbsize :- db2 "call get_dbsize_info(?,?,?,-1)" | sed -n '8p' | awk -F : '{print $2}' dbsize=`db2 "call get_dbsize_info(?,?,?,-1)" | sed -n '8p' | awk -F : '{print $2}'` echo $dbsize when I execute it the syntax works but it's not... (11 Replies)
Discussion started by: lazydev
11 Replies

10. Shell Programming and Scripting

Assign two dimensional array in bash at once

Hi, I have a 10*10 two dimensional array. How do I assign value to all it's 100 elements at once? I don't want to open two for loops and assign one by one. Thanks, Amit (2 Replies)
Discussion started by: amit14august
2 Replies
DwtMenuBar(3Dwt)														  DwtMenuBar(3Dwt)

Name
       DwtMenuBar, DwtMenuBarCreate - Creates a menu bar widget to contain menus.

Syntax
       Widget DwtMenuBar(parent_widget, name, entry_callback,
			    help_callback)
	    Widget parent_widget;
	    char *name;
	    DwtCallbackPtr entry_callback;
	    DwtCallbackPtr help_callback;

       Widget DwtMenuBarCreate (parent_widget, name,
				override_arglist, override_argcount)
	    Widget parent_widget;
	    char *name;
	    ArgList override_arglist;
	    int override_argcount;

Arguments
       parent_widget
		 Specifies the parent widget ID.

       name	 Specifies the name of the created widget.

       entry_callback
		 If  this  callback  is  defined,  all menu entry activation callbacks are revectored to call back through this callback.  If this
		 callback is NULL, the individual menu entry callbacks work as usual.  For this callback, the reason is DwtCRActivate.	This argu-
		 ment sets the DwtNentryCallback attribute associated with DwtMenuCreate.

       help_callback
		 Specifies  the callback function or functions called when a help request is made.  This argument sets the DwtNhelpCallback common
		 widget attribute.

       parent_widget
		 Specifies the parent widget ID.

       name	 Specifies the name of the created widget.

       override_arglist
		 Specifies the application override argument list.

       override_argcount
		 Specifies the number of attributes in the application override argument list (override_arglist).

Description
       The DwtMenuBar and DwtMenuBarCreate functions create an instance of the menu bar widget and return its associated widget ID.  When  calling
       DwtMenuBar,  you  set  the  menu bar widget attributes presented in the formal parameter list.  For DwtMenuBarCreate, you specify a list of
       attribute name/value pairs that represent all the possible menu bar widget attributes.

       A menu bar widget is a composite widget that contains pull-down menu entry subwidgets.  The subwidgets handle most of the I/O activity that
       display	information  and  query  the user for input.  The menu bar widget provides no input semantics over and above those provided by its
       subwidgets.

       If the menu bar does not have enough room to fit all its subwidgets on a single line, the menu bar attempts to wrap the	remaining  entries
       onto additional lines (if allowed by the geometry manager of the parent widget).

       The menu bar widget works with these widget classes: pull-down menu entries, labels, and separators.

       If  DwtNentryCallback  is  not  NULL when it is activated, all subwidgets call back to this callback.  Otherwise, the individual subwidgets
       handle the activation callbacks.

Inherited Attributes
       ------------------------------------------------------------------
       Attribute Name	       Data Type	Default
       ------------------------------------------------------------------
       Core Attributes

       DwtNx		       Position 	Determined by the geome-
						try manager
       DwtNy		       Position 	Determined by the geome-
						try manager
       DwtNwidth	       Dimension	16 pixels
       DwtNheight	       Dimension	Number of  lines  needed
						to display all entries
       DwtNborderWidth	       Dimension	One pixel
       DwtNborder	       Pixel		Default foreground color
       DwtNborderPixmap        Pixmap		NULL
       DwtNbackground	       Pixel		Default background color
       DwtNbackgroundPixmap    Pixmap		NULL
       DwtNcolormap	       Colormap 	Default color map
       DwtNsensitive	       Boolean		True
						Note  that  setting  the
						sensitivity of the  menu
						bar  causes  all widgets
						contained in  that  menu
						bar  to  be  set  to the
						same sensitivity as  the
						menu bar.
       DwtNancestorSensitive   Boolean		The  bitwise  AND of the
						parent widget's DwtNsen-
						sitive	 and  DwtNances-
						torSensitive attributes
       DwtNaccelerators        XtTranslations	NULL
       DwtNdepth	       int		Depth of the parent win-
						dow
       DwtNtranslations        XtTranslations	NULL
       DwtNmappedWhenManaged   Boolean		True
       DwtNscreen	       Screen * 	The parent screen
       DwtNdestroyCallback     DwtCallbackPtr	NULL

       Common Attributes

       DwtNforeground	       Pixel		Default foreground color
       DwtNhighlight	       Pixel		Default foreground color
       DwtNhighlightPixmap     Pixmap		NULL
       DwtNuserData	       Opaque * 	NULL
       DwtNdirectionRToL       unsigned char	DwtDirectionRightDown
       DwtNfont 	       DwtFontList	Used   only   by  gadget
						children
       DwtNhelpCallback        DwtCallbackPtr	NULL

       Menu Attributes

       DwtNspacing	       Dimension	One pixel
       DwtNmarginHeight        Dimension	Zero pixels
       DwtNmarginWidth	       Dimension	Three pixels
       DwtNorientation	       unsigned char	DwtOrientationVertical
       DwtNadjustMargin        Boolean		True
       DwtNentryBorder	       short		Zero pixels
       DwtNmenuAlignment       Boolean		True
       DwtNentryAlignment      unsigned char	DwtAlignmentBeginning
       DwtNmenuPacking	       unsigned char	DwtMenuPackingTight (for
						all  menu  types  except
						for radio boxes)
						DwtMenuPackingColumn
						(for radio boxes)
       DwtNmenuNumColumns      short		One row or column
       DwtNmenuRadio	       Boolean		False
						True (for radio boxes)
       DwtNradioAlwaysOne      Boolean		True
       DwtNmenuIsHomogeneous   Boolean		False

						True (for radio boxes)
       DwtNmenuEntryClass      WidgetClass	NULL
						Radio	boxes,	however,
						default to  the  toggle-
						buttonwidgetclass.
       DwtNmenuHistory	       Widget		Zero
       DwtNentryCallback       DwtCallbackPtr	NULL
       DwtNmenuHelpWidget      Widget		NULL
       DwtNchangeVisAtts       Boolean		True
       DwtNmenuExtendLastRow   Boolean		True
       ------------------------------------------------------------------

Widget-Specific Attributes
       The menu bar widget does not currently support any widget-specific attributes.

Return Values
       These functions return the ID of the created widget.

Callback Information
       The following structure is returned to your callback:
       typedef struct {
			    int reason;
			    XEvent *event;
			    Widget s_widget;
			    char *s_tag;
			    char *s_callbackstruct;
       } DwtMenuCallbackStruct;
       The  reason member is set to a constant that represents the reason why this callback was invoked.  For this callback, the reason member can
       be set to:

       DwtCRActivate	    The user selected a  menu
			    entry.

       DwtCRMap 	    The  menu window is about
			    to be mapped.

       DwtCRUnmap	    The menu window was  just
			    unmapped.

       DwtCRHelpRequested   The user selected help.

       The  event  member  is a pointer to the Xlib structure XEvent, which describes the event that generated this callback.  This structure is a
       union of the individual structures declared for each event type.  For information on XEvent and event processing, see the Guide to the Xlib
       Library:  C  Language  Binding.	The s_widget member is set to the ID of the activating subwidget.  The s_tag member is set to the tag sup-
       plied by the application programmer when the subwidget callback function was specified.	The s_callbackstruct member is set to the  subwid-
       get's callback structure.

See Also
       Guide to the XUI Toolkit: C Language Binding
       Guide to the XUI Toolkit Intrinsics: C Language Binding

																  DwtMenuBar(3Dwt)
All times are GMT -4. The time now is 10:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy