15,551 Topics
![]() | |
Hi all, I'm writing this piece of code out in unix. What I want to do is pass an integer argument through the command line and then manipulate it from there. I've done char strings before but cannot seem to get it to work with int's. Once I have this … | |
i'm trying to parse a string of digits that can be 1 to 3 chars long, but how to do this is eluding me. would an isDigit method work? like this: [CODE="c"] if(isdigit(vararray[v])){ if(isdigit(vararray[v+1]) || vararray[v+1]==NULL){ if(isdigit(vararray[v+2]) || vararray[v+2]==NULL){ if(isdigit(vararray[v+3]) || vararray[v+3]==NULL){ return; } return; } return; } return; } … | |
I have this code: [CODE] #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]){ char *s = getenv ("HOME"); FILE *f; int optchar; char line[300]; char p[100]; strcpy(p, s); strcat(p, "/todo.txt"); while ((optchar = getopt(argc, argv, "r:a:ldc")) != -1){ switch (optchar){ case 'a': f = fopen(p, "a"); fprintf(f, … | |
Hi Friends, I am facing a probelm. The moment I complete a program i C (version 3), it complies successfully. However, the moment I try to run the program it says a Linker error. I have tried to sort this out through Option-Linker, but in vain. I really need you … | |
Please can anybody tell me the difference in return 0 and system ("pause"); | |
![]() | Hiya, I've got a lickle program here which reads data about people into structures and then saves their surnames in a Binary Search Tree. There is more stuff to go to that program, that is why I need structures, but at the moment [B]I can not understand why it doesn't … |
I have to hit <Enter> twice after inputting my dollar amount and store selection I think I am just missing something simple somewhere, but am going stupid looking for it. Went to the internet to try and find a good debugger, but have no idea how or where to even … | |
Please can somebody help me to concatenate names in c. I try to enter names but anytime it will teat them as separate strings. this is what I tried to do : But i was getting segmentation faults, can you figure anyway out. | |
Hi, I'm trying a few things in C, but cannot advance now. This program should read what it written in the shared memory if does not take any arguments. However if arguments are passed it should write what is passed into the memory. I can make it work if just … | |
let say I got input.txt with following thing [QUOTE] Kelly // name of student 67 // Biology Score 89 // Chemistry score Michelle 75 45 John 78 90 [/QUOTE] and I use this fscanf command to scanf all the file until EOF: while ((fscanf (input, "%s %d %d", &studName, &bioScore, … | |
Hi guys, I'm working in C in PuttY server.I'm looking for a program that can display an interactive menu that interacts with the user and also display a clock in the top right corner of the screen. So I need a program that can draw a border using C, and … | |
[code] #include<stdio.h> #include<stdlib.h> #include<conio.h> struct node { int info; struct node* llink; struct node* rlink; }; typedef struct node* NODE; NODE insert(NODE root,int data) { NODE temp,cur,prev; temp=(NODE)malloc(sizeof(struct node)); if(temp==NULL) printf("\nOut of memory"); temp->info=data; temp->rlink=temp->llink=NULL; if(root == NULL) { printf("\n1st time\n"); root=temp; return root; } prev=NULL; cur=root; while(cur != NULL) … | |
Realized something today by accident. I am asking for a dollar amount in my program, and checking to make sure it is a valid amount above $0. What I am not checking for is a character response. I have tried some stuff, and nothing seems to work. Can anyone look … | |
| |
I want to use to dimensional arrays to draw a graph. How do i go about it. I have never use it before. Please | |
So I was looking over someone elses code, and the main is unusual, no type. its just: #include <math.h> main(int argc, char *argv[]) I've come up with 2 theories: 1) It defaults to int? 2) #if/#endif directives somehow negate the need for int? Have no experience with this though, so … | |
![]() | Hi , IM TRYING TO WRITE A TEXT FORMAT PROGRAM along the lines of the algorithm & pascal code found in similar named problem in "how to solve it by computer" R.G.Dromey. What it does is take a "limit" from user and users input text...it outputs the re-formatted text as … |
Hello, I was just trying to write some simple codes to learn C. I wrote 3 functions, create a list,print a list and free a list. but i get segfault while printing the list. (by the way, list is not a list datastructure. it's just an array) In create_list, I … | |
So 2 questions. 1) MPI_Init. I'm trying a python -> c -> cluster project. So I have no problem with the python -> c, but the problem comes with the c-> cluster. I'm making a python wrapper (I believe this is the correct term) around a premade c driver for … | |
Hello, I google and search through about the 2 dimension array and I still not really understand how to do it.. for example: I got a file input called namelist.txt with following thing John Jason Leonard Kelly Kate Ash and I got the following code: #include <stdio.h> int main () … | |
Greetings All, I was wondering about how a build process goes on in Vc++. I want to know that is there any intermediate assembly file generated while building a source file as what happens with gcc. If the answer is no ,then why gcc build process has this ones step … | |
![]() | Ok, so this is confusing me alot, right now I have a structure as such: [CODE]struct f_c_8 { union { float f; unsigned char c[8]; }; };[/CODE] now I declare a variable of that type [CODE]f_c_8 Time;[/CODE] However, The following prints correct number [CODE] fprintf (output_file_pointer,"\t\tTime: %f\n",event_data->Time); [/CODE] And the … |
I am making a program that has a bunch of embedded if statements. I need random number that are between 0 and 1. In order to get really "random" numbers, I set up the program to get the seed from the cpu time. Then, to get the number between 0 … | |
I have an array of floats: float net_pay[5] . Each element is a decimal number ie. 999.99, 35.42, 318.34 etc . What I would like to do is to scan the decimal portion, in first case it would be 99 to a variable cents. I know how to do it … | |
i need help I need to display Example 23.4 and display 23 and .4 how do i do this? so i need to convert a decimal into fraction like this [url]http://www.cimt.plymouth.ac.uk/projects/mepres/book7/bk7i17/bk7_17i1.htm[/url] i need to display 4 and 0.276 | |
I am trying to make a dialog box that can open, edit and save .txt files. I referred my codes in this [URL="http://www.winprog.org/tutorial/dialogs.html"]tutorial[/URL]. How am I going to modify the code so that instead of a "save as" function, it will directly "save" the file that it opened/edited. Thanks in … | |
Does anyone here have any tips on using inb and outb for interacting with hardware on a Linux system? iopl(2) and inb(0x61) don't seem to work very nicely... Infact, inb(0x61) gives me a segfault. PS: My reliance on this forum is starting to become embarrassing :P | |
This is a just simplified case because my C file is too big to post it here: [CODE=C] int main(int argc, char **argv) { GtkWidget *window, *vbox, *toolbar, *locationentry; GtkToolItem *locationbar; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); vbox = gtk_vbox_new(FALSE, 0); toolbar = gtk_toolbar_new(); locationentry = gtk_entry_new(); locationbar = gtk_tool_item_new(); gtk_container_add(GTK_CONTAINER(locationbar), … | |
[code=c] #include<stdio.h> #include<conio.h> typedef struct { int rno; char name[10]; float marks; }stu; stu stu3; void getf(stu * stutmp); void show(stu * stutmp); void main() { clrscr(); getf(&stu3); show(&stu3); getch(); } void getf(stu *stutmp) { scanf(" %d",&stutmp->rno); printf("%d\n",stutmp->rno); scanf(" %s",stutmp->name); printf("%s\n",stutmp->name); scanf(" %f",&stutmp->marks); printf("%f\n",stutmp->marks); getch(); } void show(stu * stutmp) … | |
Greetings, Is there any way may be some tools to view and explore contents of .obj files (in a formatted or unformatted way) or an executable. Can we do it using gcc? Please guide. Cheers!! | |
Hi everyone, So I am writing this program that is supposed to do the following: Create a program that accepts a string from the user (not from the command line) and displays: 1. The string using upper-case letters, e.g. all lower-case letters are converted to upper-case letters 2. The string … | |
Hello, Could anyone assist me in starting out with pointers. I know that pointers direct to the memory location where a value is stored, but I am having some issues with understanding the concept with arrays. Could you suggest a simple startup code, where a pointer points to a memory … | |
Hi, Need help to write the below mentioned program. Create an employee struct with following fields EMP_NAME EMP_ID DOJ (Date of joining) Read in the values from a file and store them in the above structure. Print the employee details if an EMP_ID is given. Regards, Shaju | |
hello, i am trying to store some values in an array dynamically. doing this as i dont want to over allocate memory to my array. so the code goes as follows:: [code] #include<stdio.h> #include<stdlib.h> int *p; main() { int i; for(i=1;i<6;i++) { p= (int *)malloc(sizeof(int)); *p++ = i*i; } printf("\n … | |
I write a small program like following: 1, firstly create a process waiting for keyboard input commands(via getchar()). 2, secondly create a thread in the process waiting on a message queue. each time after the thread receive a message, it can handle the message but cannot print the log message(via … | |
This is a catalogue of some experiments on just two aspects of undefined behaviour. This was inspired by yet another long bout of explanation in a recent thread, so I thought it was time to dust off a bunch of compilers, and compare. This is the test code. [code] #include … | |
this is the code #include<stdio.h> void main() { int i; printf("%d, %d",++i,i++); } and following is the output 8429558, 8429556 | |
Hello, i can not quite figure out how to write a function to take numbers from an array and sort so it displays even numbers first and then odd numbers. the output should look like this: [QUOTE]Original: 9 8 7 6 5 4 3 2 1 Reversed: 1 2 3 … | |
I'm a .net programmer so forgive me if this is a stupid question, but here goes. I'm working with a vendor to interface our system with theirs. We are sending text data via modem. The protocol specifications they have given us require a checksum value to be appended to the … | |
After going through lots of stuff about declaration and definition,in a nutshell I understand that the difference is in the memory allocation. In definition yes and in declaration no memory is allocated. Fine ,Is there any process that shows that yes [code] int a; //which is a definition [/code] allocates … | |
Hi Everyone, I am having some trouble with the code I am writing. I am supposed to find the sum all ASCII codes in the string, omitting the newline character at the end of the user input. Here are the directions I am given: Create a program that accepts a … | |
Hi guys....i have a problem and I hope you can explain me where am I wrong... I am doing some kind of Breadth First Search (BFS) ("some kind of" because this is my first program to use this algorithm) I have an array of size 4^9 (262144 for those of … | |
![]() | Hi, I already asked but haven't had an answer. What I am trying to do is to write a program which will read the data from the file into BST with the ability to search by surname (surname is the key). After sleepless nights I have managed to do something, … |
When i was runnning the graphucs c program in turbo c the program was terminated. I gives an error message as 16-bit MS DOS subsystem The NTVDM CPU has encountered an illegal instruction. CS:d000 IP:03e2 OP:ff ff eb 05 ea Please provide me the solution I also tried using dosbox.. … | |
Hi, This is a basic question that's why i am confused. When I do printf("%d",sizeof(long double)) in Linux(i am using a vmware) Ans:12 bytes in msvc 2008 Ans:8 bytes My underlying arch for both implementation is intel IA32. What is the reason if the arch is same.If the fundamental data … | |
Hi, I've just started using Netbeans 6.5.1, and I was wondering if you can run a single C file independently of the other C files in the project. This works for java. For example, you can run test1.java and test2.java independently in the same Java project. But it doesn't seem … | |
Can someone help me to write a code in C Programming that will ask the user to enter a PIN and if the PIN is entered 3 times wrongly the program should exit. Thanx in advance....... | |
I am new to C programming and have been using the GOTO all over the place until today when I was informed it is not preferred practice, and due to its adverse affects on debugging and maintenance should only be used in the rarest of cases. I can understand that … | |
/* File: Kilowatt-hours.c Calculate and print bills for the city company.*/ #include <stdio.h> int main() { int account_number; char code; double bills, kilowatt_hours, peak_hours, off_peak_hours; printf("Please enter Your account number: \n"); scanf("%d", &account_number); printf("Enter Your user code [R/C/I]: \n"); printf("R = Residential\n"); printf("C = Commercial\n"); printf("I = Industrial\n"); printf("\nCode = … | |
hey guys how would i figure out if a string has a number in it without using any aditional libraries? |
The End.