1,494 Posted Topics
Re: [QUOTE=Fredczj;1074677]Hi all, I face a problem using gcc and ld on embedded target. I just want to declare a constant value (designed to be located in flash memory), and I want to have it compile, linked and allocated in my output file. For instance: [CODE]const volatile unsigned long myvar __attribute__((section(".flashdata"), … | |
Re: Try checking each character that is entered like below: [CODE] char ch; while ((ch = fgetc(stdin)) != '\n') { //check if ch is a digit } [/CODE] | |
Re: [QUOTE=es cape85;1066322]hi guys! plz help with the code in C which can calculate the fectorial of 500.[/QUOTE] Could we see what you have so far. | |
Re: I think I understand what you want - try investigating the isdigit() function. | |
Re: [QUOTE=theemerchant;1060189]Hey Guys, Ubuntu just released it's 9.10 version called "karmic Koala". I'm still on the process of updating my old OS but I heard a lot of great things about it. One even mentioned it is a great competitor for Windows 7. Does anyone have something to share about the … | |
Re: [QUOTE=bj35man;1065921]it destroy the data in my hard dirve.[/QUOTE] It really depends by what you mean "it destroy the data in my hard dirve". If you mean the entire USB drive was overwritten then your data is gone. If you mean it changed some of the data on the drive them … | |
Re: Boy something is wrong here...This is the C forum | |
Re: Please post the code you have so far and the questions... | |
Re: [QUOTE=dark1806;1063201]hi..pls help me with this ...when i run this c program i get in result segmentation fault message (i run in ubuntu terminal): [CODE=c]#include<stdio.h> #include<utmp.h> int main() { char *s,*c; struct utmp *u; int i; c=getlogin(); setutent(); u=getutent(); while(u!=NULL) { if(u->ut_type==7 && strcmp(u->ut_user,c)==0) { printf("%-12s",u->ut_user); printf("%-9s",u->ut_line); s=ctime(&u->ut_time); for(i=4;i<16;i++) printf("%c",s[i]); printf("(%s",u->ut_host); … | |
Re: Try adding this to your if statement: [CODE] if(str[i] == 'a') { a++; } else if(str[i] == 'b') { b++; } else if (str[i] == '\n') { //this will account for the newline } else { stop++; } [/CODE] | |
Re: [QUOTE=Iam3R;1059987]Hi , I read that c is not a block structured language. means it does not allow defining functions inside other functions. but this code is not generating any error not even warnings, though we nest the functions. whats the story. [CODE] #include<stdio.h> int main() { int num; num = … | |
Re: [QUOTE=9868;1058214]Hello everyone, Here's my code for making a dynamic array(the user inputs the size of the array). It's working fine but I think that I've not made the best code. Is there any suggestion for improvement or optimization? [code] #include <stdio.h> #include <stdlib.h> int main(void) { int *p; int n,i; … | |
Re: [QUOTE=Jelmund;1051096]Hello people :) My teacher gave me a new project to work on. I need to write an application that output all the letters of the alphabet in a random order. I've made some applications before but im still kinda new to this. Could any of you give me a … | |
Re: The include statement is processed by the preprocessor so it can't be dynamically created in the executable... If you want to do this try Dlls | |
Re: [QUOTE=Mattpd;1056676]So I have this project to program an "auto parts management" C program. Basically I need to be able to add and delete lines of text from a text file. Also, I need to be able to edit lines of text. Lines of text are in the format: PART NAME … | |
Re: Try: [CODE] connectSocket= accept(listenSocket, NULL, NULL); [/CODE] Also I would check if an error returned on the two lines [CODE] bind(listenSocket,(struct sockaddr*)&serverAddress,sizeof(serverAddress)); listen(listenSocket,BACKLOG); [/CODE] | |
Re: [QUOTE=neithan;1054427]Hi everyone, i have this portion of code [CODE=c]while(c = getc(file) != EOF)[/CODE] c is an int and file is a FILE *file = fopen(filename, "r"); The filename points to a file with 2 lines, 10 characters total. That while always makes c a value of 1 (accodring to ASCII … | |
Re: [QUOTE=beatenbob;1053459]Hi all. Just a simple question but I SERIOUSLY need some help from you guys for my programming assignment. The assignment given was water jug problem. Now my question is, does C allow for the creation of dynamic array during a recursion? Suppose I have another function, which returns a … | |
Re: check out what I did here, I put three fprintf lines in here to check the values you are entering in your char**...Also this program had many errors...It won't compile for me so I changed some of it Also why do you use a function pointer???? Note I quickly went … | |
Re: [QUOTE=userits;1049129]include<stdio.h> void main() { int i=5; int c; c=i++ + ++i + i++ + --i; printf("\n%d",i++ + ++i + i++ + --i); printf("\n%d",c); } The o/p that I'm getting is 31 23 while my friend got 34 20. Also why are the 2 (printf ' c 'and printf 'expression') values … | |
Re: [QUOTE=hosh;1048346]Hi i'm trying to compile this code, but getting warning. need some help to understand what I'm doing wrong. void printGraph(FILE *out, GraphRef G){ out = fopen (out, "w"); if( out==NULL ){ printf("Unable to open file %s for writing\n", out); exit(1); } } warning: passing arg 1 of `fopen' from … | |
Mandriva 2010 has just been released [url]http://www2.mandriva.com/downloads/[/url] | |
Re: This function returns the address of the local variable str [CODE] char * leer() { char str[LONG], *p; int c; p = str; while((c = getchar()) != EOF) { if(c == '\n') { *p = 0; break; } *p = c; printf("p = %p, *p = c = %c\n", p, … | |
Re: [QUOTE=kgomes;1047181]In an assignment for class we have to ask the user how many characters they'd like to enter and then read the characters into an array of that size. I've had problems with calling a function to do this. I will also be passing this array to other functions, so … | |
Re: What is this program supposed to do? If you could give us an example...say When I run this program and I'm prompted for this and I press this - this happens, when in fact this should happen...I hope this makes sense | |
Re: Try defining your string "instruction" like below... Also if you have errors in the future could you post them [CODE] /* Libraries */ #include <stdio.h> #include <string.h> char instruction[] = "add h'13', 4";//not a constant now /* Main Function */ int main() { /* Declarations */ char *action; char *number; … | |
Re: Try this link...it has it all broken down [url]http://makepp.sourceforge.net/1.19/makepp_tutorial.html[/url] | |
Re: Here's a simple one: [CODE] #include <stdio.h> #include <stdlib.h> int main(int argc, char**argv) { fprintf(stdout, "ans->%u\n", 0xe5f6b7); exit(EXIT_SUCCESS); } [/CODE] | |
| |
Re: Check out this link [url]http://www.fluendo.com/shop/product/fluendo-mp3-decoder/[/url] | |
I wrote this very small program that works fine until I remove the comments for the fprintf function. Basically the program will prompt the user for a numeric value, when the user guesses right(1234) the program exits. When I remove the comments the program never exits...Does anyone have any idea … | |
Re: I just copied and compiled your code without issue on a Linux box using gcc filename.c -o filename | |
Re: [QUOTE=shakunni;1042866]As part of my program, I have defined and initialized a structure. But when I compile it, gcc gives me the following error on all the initialization " initializer element is not constant". Anyone know why this is the case? [code] struct RECORD { char* username; char* password; char* type; … | |
Re: This is line 111 [CODE] height_earth = double distance_earth(float speed, double radians)* (tan(radians)) - (G_earth * (pow(double distance_earth(float speed, double radians), 2))) / ((2(pow((speed)(cos(radians), 2))))); [/CODE] should probably be: [CODE] height_earth = distance_earth(speed, radians)* (tan(radians)) - (G_earth * (pow(distance_earth(speed, radians), 2))) / ((2(pow((speed)(cos(radians), 2))))); [/CODE] | |
Re: [QUOTE=bethesda;1042976]When I do this: [CODE]la $a1, 9($t1)[/CODE] the code works, but when I do this: [CODE]marker: .word 9 la $a1, marker($t1)[/CODE] The code doesn't work.... I don't understand why....?[/QUOTE] I'm not familiar with the above syntax so this is a guess....when you place 9 into the label marker you place … | |
Re: Are you posting your entire homework assignment? | |
Re: So what your saying is the fields are comma separated and the records are newline separated? | |
Re: You could try something like below...I generally don't like the solution but it works for some situations [CODE] #include <stdio.h> #include <stdlib.h> #define t " " int main(int argc, char**argv) { fprintf(stdout, "this\tis\ta\ttest", stdout); exit(EXIT_SUCCESS); } [/CODE] | |
Re: If you have an error message please...please copy it down and pass it on to us... | |
Re: Try this [CODE] #include <stdio.h> #include <string.h> char *VAR1(char *VAR2) { static char VAR3[12] = "Hello "; strcat(VAR3, VAR2); return VAR3; } int main(void) { printf("%s", VAR1((char*)"World!")); // Hello World! return 0; } [/CODE] | |
Re: I have this old piping program example...maybe you'll get something out of it. Usage ./filename ps wc will pipe the output of ps into wc [CODE] #include <unistd.h> enum PIPES {READ, WRITE}; int main(int argc, char**argv) { if (argv[2]) { int hpipe[2]; pipe(hpipe); if (fork()) { close (hpipe[WRITE]); dup2 (hpipe[READ], … | |
Is this the proper way to zero the first 12 bits of an address? [CODE] void *ans = (void*)((unsigned long)addr & ((0UL - 1) ^ 0xfff)); [/CODE] Where addr is any user process memory address.. Note this method works...I just want to know if there is a better way | |
Re: [QUOTE=Kombat;1040077]Ok so I make my masks [CODE] short m1, m2, m3, m4; m1 = 0xF000; m2 = 0x0F00; m2 = 0x00F0; m3 = 0x000F; [/CODE] and then I test my masks [CODE]printf("%hd %hd %hd %hd\n", m1, m2, m3, m4);[/CODE] when I test it the values come out as [CODE]-4096 240 … | |
Re: Could we see what you have so far? | |
Re: [QUOTE=Yee;1039033]Hi! I have had to change from Python to C because of university instructions. My problem is that, when I want to make a menu for my program or whatever, I always want to define classes:P My question is simple --> are structures the best way to "replace" classes? TY[/QUOTE] … | |
Re: [QUOTE=spatel14;1035873]How do I generate random numbers in C? The user doesn't enter anything, I'm just looking for a way to generate random numbers every time I run the program. Thanks guys![/QUOTE] I would lookup random or srandom...for pseudo random functions in C | |
Re: [QUOTE=group256;1038122]Hey everyone, For my project, I need to write an assembly/C code to detect multiprocessors. I really have no idea how as I have barely done assembly coding and I have no good reference or even idea how to start. Again, what I am going to do is, I'm trying … | |
Re: [QUOTE=MajesticMoose;1038395]I need a function that returns the name of a key directly from the keyboard, eg, the input of '32' would return 'Space'. I know there is a function that does this, but I can't figure out which one.[/QUOTE] I know this is knit picking but....You can't get the name … | |
Re: I passed this posting numerous times and I always wondered how do you define what your string is...i.e. can your string span more than one line in your text file, can your string overlap, can it overlap many times...with these questions bouncing around in my head the only way I … |
The End.