1,494 Posted Topics

Member Avatar for Fredczj

[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"), …

Member Avatar for gerard4143
0
193
Member Avatar for titosd

Try checking each character that is entered like below: [CODE] char ch; while ((ch = fgetc(stdin)) != '\n') { //check if ch is a digit } [/CODE]

Member Avatar for anonymous alias
0
171
Member Avatar for es cape85

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

Member Avatar for jephthah
0
98
Member Avatar for newcoder777

I think I understand what you want - try investigating the isdigit() function.

Member Avatar for hichnam
0
120
Member Avatar for theemerchant

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

Member Avatar for theemerchant
0
100
Member Avatar for simpatar
Member Avatar for bj35man

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

Member Avatar for bj35man
0
93
Member Avatar for asadc
Member Avatar for myheart
Member Avatar for Seten
0
111
Member Avatar for dark1806

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

Member Avatar for dark1806
0
133
Member Avatar for D_switch

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]

Member Avatar for gerard4143
0
116
Member Avatar for Iam3R

[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 = …

Member Avatar for Aia
0
93
Member Avatar for 9868

[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; …

Member Avatar for Narue
0
93
Member Avatar for Jelmund

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

Member Avatar for zortec
1
236
Member Avatar for ahamed101

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

Member Avatar for gerard4143
2
1K
Member Avatar for Mattpd

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

Member Avatar for Mattpd
0
151
Member Avatar for shahab.burki

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]

Member Avatar for gerard4143
0
246
Member Avatar for neithan

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

Member Avatar for neithan
0
99
Member Avatar for beatenbob

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

Member Avatar for gerard4143
1
411
Member Avatar for arsh_arsh

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 …

Member Avatar for gerard4143
0
111
Member Avatar for userits

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

Member Avatar for Aia
2
141
Member Avatar for hosh

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

Member Avatar for Aia
0
84
Member Avatar for gerard4143

Mandriva 2010 has just been released [url]http://www2.mandriva.com/downloads/[/url]

Member Avatar for Stefano Mtangoo
0
149
Member Avatar for neithan

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

Member Avatar for gerard4143
0
155
Member Avatar for kgomes

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

Member Avatar for gerard4143
1
96
Member Avatar for bufospro

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

Member Avatar for bufospro
0
133
Member Avatar for pmee

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

Member Avatar for pmee
1
101
Member Avatar for cabosun

Try this link...it has it all broken down [url]http://makepp.sourceforge.net/1.19/makepp_tutorial.html[/url]

Member Avatar for gerard4143
0
114
Member Avatar for hapyharra

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]

Member Avatar for gerard4143
0
163
Member Avatar for want_to_code
Member Avatar for Iam3R

Check out this link [url]http://www.fluendo.com/shop/product/fluendo-mp3-decoder/[/url]

Member Avatar for gerard4143
0
109
Member Avatar for gerard4143

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 …

Member Avatar for gerard4143
0
133
Member Avatar for cabosun

I just copied and compiled your code without issue on a Linux box using gcc filename.c -o filename

Member Avatar for gerard4143
0
81
Member Avatar for shakunni

[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; …

Member Avatar for shakunni
0
130
Member Avatar for A Tripolation

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]

Member Avatar for banders7
0
242
Member Avatar for bethesda

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

Member Avatar for bethesda
0
90
Member Avatar for shakunni
Member Avatar for shakunni

So what your saying is the fields are comma separated and the records are newline separated?

Member Avatar for gerard4143
0
105
Member Avatar for Sarang07

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]

Member Avatar for Sarang07
0
89
Member Avatar for wangatang126

If you have an error message please...please copy it down and pass it on to us...

Member Avatar for stephen186
0
104
Member Avatar for raigs

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]

Member Avatar for Dave Sinkula
0
394
Member Avatar for symmet

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

Member Avatar for gerard4143
0
177
Member Avatar for gerard4143

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

Member Avatar for Dave Sinkula
0
164
Member Avatar for Kombat

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

Member Avatar for Dave Sinkula
0
138
Member Avatar for HypnotiqBIG
Member Avatar for Yee

[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] …

Member Avatar for gerard4143
0
102
Member Avatar for spatel14

[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

Member Avatar for Chilton
0
133
Member Avatar for group256

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

Member Avatar for gerard4143
0
314
Member Avatar for MajesticMoose

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

Member Avatar for gerard4143
0
141
Member Avatar for Grn Xtrm

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 …

Member Avatar for Tajon Wong
0
3K

The End.