- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 9
- Posts with Upvotes
- 9
- Upvoting Members
- 9
- Downvotes Received
- 7
- Posts with Downvotes
- 7
- Downvoting Members
- 6
78 Posted Topics
Re: [QUOTE=~s.o.s~;234971]Based on the request by Mr. Jamshid i thought why not just start the useful links and tutorials for novice C programmers so they dont have to do a lot of GOOGLE like the one present in Python Forums. If the moderators like the concept here they can sticky this … | |
Hi, When i debug the program using gdb , the gdb is entering the definations of std lib functions (ex: printf, strcpy ect) and other internal functions. Initially the debuger was working fine, i dont have clue when it got changed.I guess some of the flags of gdb might have … | |
Hi , I am trying for a program which takes any no of characters as input and stores, so obviously i would need DMA. My approch is to Take a buffer of some fixed size(5 in this case) Fill the buffer till the fixedsize-1 Allocate memory dynamically and store the … | |
hi, i have seen somany people asking about fnding loops in a single linked list. i would like to know is there any advantange or necessity for having loops in a linked lists. is there any application that really requires loops in lists. Thanks, Gaiety | |
I have some strange problem which i started facing from yesterday. i have used GDB many times on my system , but yesterday when i started running GDB , my dubugger is enterings the library functions code part also which is very irritating for me. I mean if the program … | |
I have executed the below program several times, most of the time i got the same out put but some times output is different. sample out put is: > skylab@skylab:~/Nx/Thrds$ gcc 3.c -lpthread > skylab@skylab:~/Nx/Thrds$ ./a.out > Scheduling policy = ??? > arg = 20 > 1arg = 20 > … | |
Hi, Can somebody please explain , printing with structure variable also working. int main( void ) { struct bitfs { unsigned char a:4; unsigned int b:5; }; struct bitfs bf = {15,31}; struct bitfs2 { unsigned char a:4; unsigned int b:5; }bf2 = {15,31}; printf("a= %u \n", bf.a); printf("b= %u … | |
Hi, I know i am asking a question which can be googled and find lot of explanation. I have actually gone through many but none explained the ownership property completely. > Mutex is acquired by some process, only that process can unlock it how the other process/thread know that the … | |
Hi, I have added sleep with random timings and printed the values. I am actually expecting the "Blocked in Child" OR "Blocked in Parent" out put when other process sleeps. But it it never printing the statement.(when the process is going to sleep the semaphore is not cleared so i … | |
Hi All, I have read that the system call "execlp" will take the first arguement as the file name(or path), second arguement as the command and all others are arguements to the command terminated by NULL. i have written below program. [CODE] #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> … | |
Re: The value of a is used after it is incremented twice ie 7. but such expression behaviours are not defined by standards. [url]http://c-faq.com/expr/ieqiplusplus.html[/url] | |
Re: The simplest i can think is to include the below [CODE] for(input;input!='x';input=getchar()) { if (!isspace(input)){ switch(input) { ...... ...... } } } [/CODE] | |
Hi, I want to print the word that start with h(not case sensitive). i tried with below code but its printing only one charater 'H'. i dont understand the metacharaters and regular expressions much. i understood that $1 will have the first match and $2 will have second match and … | |
Hi, I have just started learning PERL. below is the code i have written , i am expecting the same order that of array when i print the contents. but the output was [ICODE] 29 25 Michael 29 Walter 34 Donny 25 Sobzchak 30 [/ICODE] can some body please clarify … | |
Hi , what is the behaviour of below pseudo code. [CODE] pipe(fd) if(fork()){ read(fd[0]); } else { write(fd[1]); write(fd[1]); } [/CODE] I understand how system calls work , but could not understand the behaviour when used differently. secondly if a process uses while(1); in side its block, will the entire … | |
I have created few files and Makefile in the same place. I have read in below link about the special variables $@ and $< and used as so. [URL="http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/"]http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/[/URL] but when the say make i keep getting the error [ICODE]gcc -o calc *.o /usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/../../../crt1.o: In function `_start': (.text+0x18): undefined reference … | |
Re: [CODE][/CODE][CODE]fscanf(fp,"%lf\n", event); [/CODE] requires address of variable so use [CODE]fscanf(fp,"%lf\n", &event); [/CODE] lly, [CODE]fprintf(fw, "%d\n" , &time_bins[j]);[/CODE] does not need address to print [CODE]fprintf(fw, "%d\n" , time_bins[j]);[/CODE] is sufficient. | |
[CODE] #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main( void ) { int fd,nob; char str[1024]; fd = open("test.txt",O_RDWR|O_CREAT,S_IRWXU); if (fd < 0) { perror("open:"); exit(0); } nob = write(fd,"hello first",1024); close(fd); printf(" %d nob written",nob); fd = open("test.txt",O_RDWR); nob = read(fd,str,1024); close(fd); printf(" %d nob … | |
Re: what is the meaning of largest sum of contiguous integers. i understood it as below. ( correct me if wrong ) consider the elements of the array are -1, 2, -3, 2, 0, 5, -11 so the sums of contiguous elements will be [ICODE] (-1) + 2 + (-3) + … | |
Hi, I just started unix programming . below are the two files i am using for reading/ writing from/to a named pipe called RNP. read.c is run on one terminal and write.c is run on other terminal. write.c is accepting the input , but read.c is not reading the input … | |
Re: [QUOTE=tejaspandey;1722398][CODE] #include <stdio.h> #include <stdlib.h> int main() { FILE *fp; char ch; fp=fopen("exp.txt","w"); while( (ch=getchar()) !=EOF) { putc(ch,fp); } fclose(fp); return 0; } [/CODE] I am using gcc compiler in linux mint This code is not working only exp.txt is created which is empty.[/QUOTE] your program is correct , just … | |
Hi, I have recently gone through some C internal stuff, addressing schemes(logical,relocatable and physical). what i dint get here is how are these inter-related.I do understand that these three are genearated by different tools. I want to know how exactly one is useful for other in executing the program in … | |
Hello , i have read the manual page of alloca , it is documented there that "alloca works similar to the malloc but it allocates memory from stack and frees automatically. i can't get how can i use that in a program . if i'm not wrong can i use … | |
Hi, if any one has any idea "how the switch statement works". does it maintain any tables internally or any other machanism? and is there any way to make the switch statement efficient? | |
Re: [QUOTE=needhelpe;1016179]how can I output 123454321, if i input 5. and 1234321 if i input 4?[/QUOTE] you could do that by following below read count; [CODE]for(start = 1; start <= conut; start++) putchar( start + '0' ); for(start = start -2; start > 0; start--) putchar( start + '0' );[/CODE] | |
below is the code for traversing a binary tree without using recursion but the problem with the code is we require array of pointers to store all the nodes address. in below program the parameter nodes in the function push is an array of pointers to store all the node … | |
Re: [QUOTE=Narue;1063789][B]>Can someone explain me what does this mean? >"40[^\"], %*c"[/B] Assuming it's actually "%40[^\"], %*c", it means read a string of up to 40 characters or until a double quote is found (%40[^\"]), then match a comma, any amount of whitespace, and ignore the next non-whitespace character (%*c). The %[ … | |
Re: specify the requirements clearly : what do you want to store in linked list numbers or names(strings). if numbers are to be stored use scanf else use fgets or you can define one safe function for reading strings. post your program here so that you will get some guidelines on … | |
[CODE]/* Function to find prime number if so return 1 else return 0 */ #include<stdio.h> #include<math.h> int isprime( int num ) { int i ; int sq = ( int ) sqrt ( num ); /* here check should be done for num = 0 and 1 other wise 0 … | |
i am clear with the concept of Array of pointers & pointer to an Array. but i wonder what is the advantage of creating a pointer to an array though the same can be done just by using twod array with row and col indexes. please some let provide me … | |
Is there any problem with the code . Why this code is generating all offsets as 28. [CODE] #include<stdlib.h> #define offsetof( T , M ) (( size_t )(( char *)&(( T *)0) ->r - \ (char *)(T *) 0)) int main(void) { struct STU { char name[20]; struct DATE { … | |
[CODE] #include<ncurses.h> int main() { WINDOW *win ; initscr(); win = newwin(10,30,10,10); box( win, ACS_VLINE, ACS_HLINE); refresh(); wrefresh(win); mvwprintw(win , 13, 14, "Enter any Key :\n "); refresh(); wrefresh(win); getch(); refresh(); wrefresh(win); endwin(); printf("END"); return 0; } [/CODE] I just started learning Ncurses and have some questions: i understand that … | |
why we have an int type when we already have short and long ints because int means either short or long. | |
I am writing a program to create a window and a box in which the statements are printed but i am unable to get the correct out put. some times after executing the program its showing the commad line but what ever the commands i enter are not visible at … | |
Re: [QUOTE=chet6;1041613]Hi, Could anyone please explain how the memory allocatio is done in case of double pointers?[/QUOTE] int var = 10 ; int *pvar = &var; int **ppvar = &pvar; here [ICODE]var[/ICODE] is 10. and this will be stored in some memory say that is 1000 (i.e &var =1000) so var … ![]() | |
Re: [QUOTE]Please tell me how will be the correct program to get correct output[/QUOTE] where is your program--------> | |
Re: [QUOTE=Aia;1026854]Take a look at its prototype. What type does getch() return?[/QUOTE] int getch(void); returns an integer value so whats the problem, atleast it should print some value. | |
Re: [CODE] for (counter1=0;counter1<row;counter1++) { *(ptrA+counter1)=(int*)(calloc(column,sizeof(int))); *(ptrB+counter1)=(int*)(calloc(column,sizeof(int))); *(ptrC+counter1)=(int*)(calloc(column,sizeof(int))); } [/CODE] (i) why are you allocating memory for ptrB and ptrC. you are not using them at all. (ii) [CODE] scanf("%d",**((ptrA+counter1)+counter2));[/CODE] is wrong, it should be [CODE]scanf("%d",&(**((ptrA+counter1)+counter2)));[/CODE] if you want to allocate memory for two D array. you can do it simply … | |
Re: A linked list is a data structure in which it contains the nodes. a node is a structure it contains the data field and a pointer field. the data field can be anything, and the pointer field contains the address of the next node. so the structure should be struct … | |
Re: you are reading the file in wrong order here is a sample [CODE] void read() { FILE *fp; int x; char t1[50],t2[50]; float f1,f2; fp=fopen("read.txt","r"); if(fp) { while((x=fscanf(fp,"%s%f%s%f",t1,&f1,t2,&f2))!=EOF) { printf("x=%d\n",x); printf("%s\n %f\n %s\n %f\n",t1,f1,t2,f2); getchar(); } printf("END x=%d\n",x); } else printf("File open failed\n"); fclose(fp); } [/CODE] | |
Re: function to display the floating number the float numbers are stored in sign exponent mantissa fashion furthur reading http://steve.hollasch.net/cgindex/coding/ieeefloat.html void test() { float f=5.25; char *p=(char *)&f; int i; for(i = 3; i >= 0; i-- ) printf("%x\n",p[i]); } refer the attachment for out put on my system . | |
Re: I think this will do.. [CODE] int main() { int a[10]={12,15,19,27,20,31,45,54,59,90}; //int a[10]={1,2,3,3,5,6,7,8,9,10}; int flag; flag=find_order(a,sizeof(a)/sizeof(a[0])); if(flag) printf("In order\n"); else printf("Not In order\n"); return 0; } int find_order(int a[],int high) { int j; for(j=0; j<high; j++) { if(a[j]<=a[j+1]) continue; else break; } if(j==high) return 1; else return 0; }[/CODE] | |
Re: every thing is correct except this it is always false [CODE] if (loan=0) cout << "Months to repay the loan =" << counter <<endl[/CODE] it should be [CODE] if ( loan == 0) cout << "Months to repay the loan =" << counter <<endl[/CODE] simple assignment operator makes life misearable … | |
![]() | Re: i dont understand your logic but here i am giiving mine. this is not so efficient but will do the same work. [CODE] #include <cstdlib> #include <iostream> #include<cstdio> using namespace std; int prime (int num); int pal(int num); void makepals(int num); int Pals[100000]; int cnt =0; int main(int argc, char … |
Re: pass the headers in the functions and return updated ones. | |
Re: I hope this will solve your problem [URL="http://www.dreamincode.net/forums/showtopic74004.htm"]http://www.dreamincode.net/forums/showtopic74004.htm[/URL] | |
Re: [QUOTE=riahc3;1023687]Hey I have a text file (1.txt) with the lines: This is line 1 This is line 2 This is line 3 This is line 4 This is line 5 and Im trying to read all the pair lines from that file and write them to another text file called … | |
Hi, if any one has the idea of the internal system calls which gets activated by using high level statements ( like printf ,scanf or malloc and so on) please provide me the links or any related info. i have an idea that the internal system calls depends on the … | |
Re: i just had a glance at your code you declared [CODE] int temp_1, temp_2, temp_3; [/CODE] and used [CODE] record.total_points = temp1; record.total_points = temp2; record.total_points = temp3; [/CODE] mismatch in variable names you must be getting compilation errors. correct the names first, and you are not updating the global … | |
Re: decalre a union with one double value and char array of 8 bytes. in Little Endian format , always the sign will be MSB. so take 7th array, and perform AND operation with 1(char) left shifted 7 times. and return the resultant value. NOTE: the returned value is not 1 … |
The End.