15,550 Topics

Member Avatar for
Member Avatar for ram619

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; }

Member Avatar for sepp2k
0
356
Member Avatar for ram619

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 …

Member Avatar for ram619
0
203
Member Avatar for hg_fs2002

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 …

Member Avatar for rubberman
0
244
Member Avatar for Vish0203

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, …

Member Avatar for Vish0203
0
172
Member Avatar for avinash7

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?

Member Avatar for deceptikon
0
158
Member Avatar for leon.lashway

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 …

Member Avatar for deceptikon
0
431
Member Avatar for dev90

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?

Member Avatar for sepp2k
0
151
Member Avatar for coding101

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 */ \ …

0
114
Member Avatar for nitin1

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.

Member Avatar for deceptikon
-2
112
Member Avatar for dev90

Answer is NING. how....? i am not getting. can any one explain please....? ‪#‎inclde‬<stdio.h> void main() { printf(2+"GOOD EVENING"+6); getch(); }

Member Avatar for dev90
0
124
Member Avatar for ram619

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 …

Member Avatar for ram619
0
228
Member Avatar for ncauchi

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 …

Member Avatar for ncauchi
0
214
Member Avatar for rahul8590

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 . ?

Member Avatar for gurumukhi
0
182
Member Avatar for lalitha2294

#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 …

Member Avatar for lalitha2294
0
153
Member Avatar for nitin1

#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.

Member Avatar for lalitha2294
0
275
Member Avatar for tanatos.daniel

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) …

Member Avatar for Sokurenko
0
293
Member Avatar for nitin1

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.

Member Avatar for deceptikon
0
110
Member Avatar for vidya s

remove a pattern "ffffff" from string "f a1 2 5 ffffffde 23 fffffff1 4 b0" using c code

Member Avatar for Gonbe
-3
232
Member Avatar for حسنين_1

**what is dynamic allocation memory.help me with example.write comments with statement**

Member Avatar for rubberman
-5
91
Member Avatar for sash_007

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 …

Member Avatar for sash_007
0
242
Member Avatar for ram619

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; }

Member Avatar for ram619
0
107
Member Avatar for Alice_Blue

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 …

Member Avatar for Laszlo_1
0
1K
Member Avatar for sujan.dasmahapa

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 …

Member Avatar for Ancient Dragon
0
350
Member Avatar for nitin1

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 …

Member Avatar for Unimportant
0
103
Member Avatar for schematicc

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 …

Member Avatar for mathematician
0
304
Member Avatar for sash_007

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 …

Member Avatar for sash_007
0
352
Member Avatar for piczim

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 …

Member Avatar for Ancient Dragon
0
127
Member Avatar for Vinod Supnekar

#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; }

Member Avatar for Gonbe
0
193
Member Avatar for Tinnin

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 …

Member Avatar for Tinnin
0
186
Member Avatar for حسنين_1
Member Avatar for Ancient Dragon
0
117

The End.