15,551 Topics
| |
Hello, I'm a C newbie (first time using C at university) and after reading a few books, I still have problem implementing & understanding structures and pointers. I have the following structure: [CODE]typedef struct data { double average; }Tdata; Tdata stat = {0};[/CODE] Now I have two functions which are … | |
I'm working on a project for school. Normally I'm a C++ guy, but I have to go through standard C before that, so I'm struggling with certain aspects being different, such as getline. Here's essentially what I'm doing, I have a data file that has a certain about of lines … | |
This is a program I wrote for class, and its completely done and compiles with no errors, but I keep getting a segmentation fault and even after using GDB and putting print lines (with fflush attached) I cannot figure out what the problem is. I do however think I found … | |
suppose I have: [CODE]#define special_for(X,Y) { register int i = 0; for (;i<X;i++) {Y} }[/CODE] It is used in the following functions: [CODE]init_lineholder(int nlines) { [COLOR="Red"]special_for(nlines, lineptr[i] = (char *)malloc(MAXLEN); tmp++;)[/COLOR] }[/CODE] AND print_lines() { [COLOR="red"]special_for(tmp, if (lineptr[(first+tmp-i)%tmp] == NULL) break;[/COLOR] else printf("%s\n", lineptr[(first+tmp-i)%tmp]) ; ) /* had to space … | |
Drawing Hello 1. Horizontal Hello 2. Diagonal Hello Enter choice: 1 * * ****** * * **** * * * * * * * ******* **** * * * * * * * * * * * * * ****** ****** ****** **** Drawing Hello 1. Horizontal Hello 2. Diagonal … | |
HOw does interpolation search work, help me with how you end up with log(logN) | |
So I have an assignment that I have been attempting for 2 weeks now and the class has been given extensions twice now. Everyone seems to be struggling with this part of the assignment. The assignment is to do K&R Exercise 5-13, unix tail command. [COLOR="Red"] Instructions: "The program takes … | |
Hi, This has been discussed ealier, but i would like to know how the loop executes 1. #include<stdio.h> 2. #include<conio.h> 3. void main() 4. { 5. int x,y,z; 6. scanf("%d",&x); 7. if(x>0) 8. { 9. y=x/10; 10 z=x%10; 11. x=y; 12. printf("%d",z); 13. } 14. printf("%d",x); 15. } Suppose I … | |
I need to edit every character of a string for an assignment; apply a simple Caesar cipher on it. What is the C equivalent of "charAt()"? I remember my prof saying that all strings are terminated with a certain character in C and that you could run a while loop … | |
I am starting to learn C basic OS Concepts and I have to code them using C. Can anyone suggest me some good links where I can get basics of the complete OS Concepts like (process,IPC,thread,sheduling,File management,Memory management, Security) I have got good idea about the concepts but I am … | |
Hi I am new to C. I want use properties file in C like how we use in "java" and "Perl". I want to read the values from a file and have to use those values in another file. This logic is to avoid hardcoding username and password. | |
Hello, I've been having problems with my program. I really don't get files that much. This is my code: [code=c] #include<stdio.h> #include<string.h> #include<stdlib.h> #include<conio.h> #define max 3 typedef struct { char FName[24]; char LName[16]; char MI; }name; typedef struct { unsigned long ID; name n; char course[8]; int level; }profile; … | |
This is part of some class work I have to do, but this is not what I am turning in as my assignment! It does have some bugs, but as long as the user only enters an integer it runs fine. I have included just the part of the code … | |
How do you add a character to an existing string? In java you could just do: char c='a'; String b="posit"; b+=c; but I tried doing that in C and it doesnt work. Is there a workaround? Thanks. | |
I need to read data from a flat file [find below] into a linked list. Each line is a record and each record needs to be read into a different node. After I open the file using fopen(), I have the following problem: 1) How do I move from the … | |
Hey, How do I create a file from a C program? I want to check if the file exists and if it doesnt, then create it. I am using the following code to check if it exists: [code] filecheck() { b=fopen("password.csv","r+w"); if(b==NULL) { // need code for creating a file … | |
Hello, I am currently trying to write a program that will read from either stdin from a file (using <) or from piped input. I have the portion using the < working because i am able to read the st_size of the file and create a read() call accordingly: read(0,&inptr,stdinfo.st_size); … | |
I want to stop the \t tab after 5 spaces, How do i do that? | |
Okayy, So. I'm required to make a new set of functions for the <string.h> library and am confused on a few things, and am wondering if anyone can help me out. I'll toss out the ones I'm struggling with. int mystrcmp(const char* s1, const char* s2); This function will compare … | |
i have just written a small program on DEV C++. i have been using it for couple of months but i never observed this error. [CODE] #include<stdio.h> int main() { printf("Welcome\n"); system("PAUSE"): return 0; } [/CODE] could not create makefile I/o error 32 any idea? what does that mean | |
Hi i have a binary function search program where the user enters a index of numbers, then enters the number he wants to find. However my program wont compile and says the subscripted value is neither an array or pointer. Help me out please. Here is what ive got: [CODE]# … | |
I was just wandering about the user interface of C applications. What are the basic things one should know about programming a graphical user interface with C. | |
A hospital keeps a file of blood donors in which each record has the following information (i) Name (ii) Age (iii) Address (iv) Contact no. (v) Blood group. I have to write a program to enter record into a data file “blood donors.dat” and display information of each donors. And … | |
i am new to unix. i have written a code for testing the basic functions read / write and open i have read that read/write returns the no of bytes read/written but here my write is returning 1 and read is returning 0 no matter how many chars i write. … | |
need to replace all occurences if substring by new string. below code replace first occurence but not other substrings present in input string. | |
Does anyone out here have an idea as to how to go bout simulating a DFA (deterministic finite automata) in C which accepts multiples of 3 ????? | |
I get this gcc warning with [I]-Wwrite-strings[/I] flag. I want to return a string of chars correctly but I also do not want to use [I]malloc[/I]. I've read other posts but can somebody explain how to acheive this in layman wording? [QUOTE]a.c:14: warning: passing argument 1 of ‘VAR1’ discards qualifiers … | |
I am new to c programming. I am trying to write a parking garage program that uses arrays to find the charge for each car and the total charge. Here is what I have so far. Please help me in any way that you can. [code=c]#include <stdio.h> #include <math.h> float … | |
[code=c] #include <stdio.h> #include <conio.h> int main(void) { unsigned port = 0; int value; value = outp(port, 'C'); printf("Value %c sent to port number %d\n", value, port); return 0; } [/code] It gives error 8 C:\Dev-Cpp\Abc\... `outp' undeclared (first use this function) How to solve this ?? I write function … | |
[CODE=C] #include<stdio.h> #include<conio.h> #include<string.h> //typedef int BOOL; //#define TRUE 1 //#define FALSE 0 int a[3][4]; int Prime(int *x); void input(); void printOut(); void checkPrime(); int Prime(int *x) { int i; for( i=2; i< (int)sqrt(*x); i++ ) { if( *x%i == 0 ) return 0; } return 1; } void input() … |
The End.