Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
int i;
memset(Deviceptr,0*00,sizeof(Deviceptr))
i=Deviceptr[0];


Then
C++
i=?

reply me the answer and explain how
Posted
Updated 2-Aug-13 20:45pm
v2
Comments
Richard MacCutchan 3-Aug-13 4:21am    
i will be zero, the contents of the first cell in the array that you have just cleared to zero. something you could easily confirm just by stepping through your code with the debugger.

1 solution

Please note:
  • Your code won't compile.
  • You are ignoring memset return value.
  • You didn't show us the declaration of the Deviceptr variable.


if Deviceptr is an array of integers then i value should be 0.


[update: fixed C code]
C
#include <stdio.h>
#include <memory.h>

#define Max_port 4

int main()
{
    char Deviceptr[Max_port];
    int i;
    memset(Deviceptr,0,sizeof(Deviceptr));
    i=Deviceptr[0];
    printf("i = %d\n", i);
    return 0;
}

[/update]
 
Share this answer
 
v3
Comments
Rajesh Varatharajan 3-Aug-13 3:21am    
char Deviceptr[Max_port];
#define Max_port 4
Rajesh Varatharajan 3-Aug-13 3:23am    
write the correct code using memset and the output for that code
CPallini 3-Aug-13 3:37am    
I updated my answer.
Rajesh Varatharajan 3-Aug-13 4:40am    
Thanks
CPallini 3-Aug-13 5:35am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900