15,551 Topics
| |
The output of this code is -1, 4, 4. I am not sure about this -1. Is it because when all bits are set then in decimal it means -1 ? #include<stdio.h> int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit={1,4,4}; printf("%d %d %d",bit.bit1, bit.bit3, bit.bit4); … | |
The output of this code is char *str="char *str=%c%s%c;main(){printf(str,34,str,34);}";main(){printf(str,34,str,34);} I don't know how this is happening. Please explain. #include<stdio.h> char *str = "char *str=%c%s%c;main(){printf(str,34,str,34);}"; int main() { printf(str,34,str,34); return 1; } | |
Hello, I am not able to understand whats happening behind "ptr-p", "*ptr-arr". Please explain #include<stdio.h> int main() { static int arr[]={0,1,2,3,4}; int *p[]={arr,arr+1,arr+2,arr+3,arr+4}; int **ptr=p; ptr++; printf("\n %d %d %d \n",ptr-p,*ptr-arr,**ptr); *ptr++; printf("\n %d %d %d \n",ptr-p,*ptr-arr,**ptr); *++ptr; printf("\n %d %d %d \n",ptr-p,*ptr-arr,**ptr); ++*ptr; printf("\n %d %d %d \n",ptr-p,*ptr-arr,**ptr); return … | |
I have this code: typedef struct { int a } array[1]; int main (array var) { if ((var->a) == 0) return 0; } and I want to copy var to a new variable. It seems it should be something like typedef struct { int a } array[1]; int main (array … | |
Hi, I am using gcc compiler to compile the program and build an exe I used this command to compile gcc program.cpp -g -o program (generates program.exe and runs fine) But, if i write the same thing in system("gcc program.cpp -g -o program"); programmatically, then the exe is generated but, … | |
According to the Gregorian calendar it was monday on the date 01/01/01. if any year is input through the keyboard write a program to find out what is the day on 1st January of this year? | |
I have learned a few programming languages and am now in the beginning stages of teaching myself C with "C Programming, Second Edition for the absolute beginner". I'm enjoying the book but have run into some difficulties in the second chapter exercies. The exercise states as follows: Create a program … | |
int arr[]={12,17}; printf("\n arr = %d , &arr= %d",arr,&arr); printf("\n arr+1 = %d , &arr + 1= %d",arr+1,&arr+1); getch(); } ans : arr=400 &arr=400 arr+1=402 &arr+1=404 Please tell me how &arr and &arr+ 1 works? | |
Need help dhcpdiscovery message...using raw sockets..dont want dhcp headers or libraries..do it myself anyway im getting error on sending my packet..any USEFUL help? #include <stdio.h> #include <stdlib.h> #include <netdb.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/ip.h> #include <sys/types.h> #include <string.h> #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ … | |
actually, this is an interview question of a company which deals with adds on mobile phones. can anyone give me hint on this ? what can be the answer of this ? it is therotical question though.thanks. | |
Answer is NING. how....? i am not getting. can any one explain please....? ‪#‎inclde‬<stdio.h> void main() { printf(2+"GOOD EVENING"+6); getch(); } | |
In this code at line number 7, 'p' is a 1D pointer then how come at the print statement it is being considered as 2D pointer ? and when we do 'a+1' then it would cross whole array. I am not able to understand this code. Please explain. Expected output … | |
I am new to C and am trying to read the characters in a string serially but I keep getting the error > makes pointer from integer without a cast This is my code void UART1PutChar(char Ch) { //char data; //transmit only if Tx buffer is empty while(U1STAbits.UTXBF ==1); U1TXREG … | |
i have written many programs using stack , but how do i write a program to find whether the stack is progressing in forward or reverse direction . ? | |
#include<stdio.h> #include<conio.h> #include<math.h>> main() { int k,i,r,n,j,a[100],m,p,b[100],count=0,count1=0,q,w,g,h,l,z,x,x1; printf("enter the length of the data word:"); scanf("%d",&k); printf("\nenter the data word:"); for(i=1;i<=k;i++) { scanf("%d",&a[i]); } r=1; while((k+r+1)>pow(2,r)) r++; printf("\n r=%d",r); n=k+r; j=1; m=0; for(i=1; i<=n; i++) { p=pow(2,m); if(i==p) { b[i]=0; m++; } else { b[i]=a[j]; j++; } } printf("\n INTERMEDIATE CODE … | |
#include main() { int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris"); } how many times sun will be printed and how many times solaris will be printed ? and reason also. i know the fundamentals of fork() but still not able to catch the o/p here. thanks. | |
I have the following code: #include <iostream> #include <conio.h> using namespace std; long filesize(FILE *stream); int main(void) { FILE *stream; char c; int i=0,n; long lSize; stream = fopen("tanc.TXT", "r"); fseek (stream , 0 , SEEK_END); lSize = ftell (stream); rewind (stream); cout<<"Dati numarul de caractere:"; cin>>n; while(!feof(stream) && i<lSize) … | |
int ** foo(int row) { int *arr[100]; for(int i=0;i<10;i++) { arr[i]=malloc(sizeof(int)*10); } int **p=(int**)arr; return p; } what is the problem with this code snippet ? it is not a homework. it is my interview question. | |
remove a pattern "ffffff" from string "f a1 2 5 ffffffde 23 fffffff1 4 b0" using c code | |
**what is dynamic allocation memory.help me with example.write comments with statement** | |
hello friends, i was recently trying to set up MInGW with eclipse kepler as discussed in this thread here http://www.daniweb.com/software-development/c/threads/459815/cant-setup-eclipse-kepler-with-mingw but offlate i am facing new issues when i try to start eclipse everytime i try to start eclipse i get this error http://gyazo.com/3551af2d1d4ea8e13733f95166b3d2fa i installed eclipse and java 3times … | |
The output of this snippet is 4 and 1. 4 is ok but why this 1 ???? #include<stdio.h> int main() { printf("%d %d",sizeof(NULL),sizeof("")); return 0; } | |
Hi all! I'm at work - newly hired:) - and I'm given this mpeg2 video codec [URL="http://www.mpeg.org/MPEG/video/mssg-free-mpeg-software.html"]http://www.mpeg.org/MPEG/video/mssg-free-mpeg-software.html[/URL] and in particular the decoder that exists in the folder mpeg2v12.zip. It is code c written for gcc, so I decided to download MinGW and DevC/C++. I add all the files to the … | |
I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines. I have created rectangle region for each line and … | |
Declare an array of function pointers that return a pointer to a func that in turn return a pointer to a char array. can you helpme in this . i have doubt in the last thing. if at the last it is "return a pointer to char", then i can … | |
I am asked to create a program that will enable the user to input something just like a text editor. Saving of the file is not required. We just have to let the user type in it(on the console/dos environment of the turboc++) just like any other text editor. What … | |
hello friends, i am new to this forum and new with C i am stuck at setting up eclipse kepler with MinGW I have my eclipse installed undder C:\Program Files\eclipse and MinGw under C:\MinGW i know MinGW needs to adjust environment variables here is screenshot for ur refernce http://gyazo.com/276678dcfacd54c15a0c332f136964d1 and … | |
I am wanting to write a program for a BMI calculator that eventually will record details for several entries. However to start with I need to be able to just complete one calculation. Below is my code which works up to the if statement what I am trying to do … | |
#include <stdio.h> int *check(); int main() { int *c; c = check(); printf("%d\n", c); return 0; } int *check() { int i=10; int *p=&i; return p; } | |
Hi All, I've just started to learn C from "The C Programming Language" (Kernighan). One of the exercises asks you to write function that folds a line of text into newlines after x number of characters without splitting a word. This is my attempt so far: // fold: folds the … |
The End.