•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 403,503 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,252 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 6197 | Replies: 50
![]() |
•
•
Join Date: Aug 2006
Posts: 24
Reputation:
Rep Power: 3
Solved Threads: 0
•
•
•
•
Damn mistake again. Theoreticalican overflow so list func must be modified
void List() { Contactbook = fopen("Contactbook.txt","r"); if(Contactbook != NULL) { int i = 0; system("clear"); printf("Current Entries: \n"); while(fgets(contactbook.names, sizeof(contactbook.names), Contactbook) != NULL) { if (i % 5 == 0) { printf("%s", contactbook.names); i = 0; } i++; } printf("End of File \n"); system("pause"); fclose(Contactbook); } else { printf("Contactbook.txt open FAIL!\n"); } }
Oh now i get it. Although have passed it up, nevermind learning is a long life process.....
one more thing, i made my edit function like this ( using delete function and then add a new value into contactbook because i don't know how to overwrite the initial value containing in the previous file) Is it we have to use fseek. but how should we know the place in the array.
and you're right with white space thing. Is it we have to replace it with fgets? but if there's too many argument, how to write it. Just want to learn more.
•
•
Join Date: Jun 2005
Location: Novi Sad, Serbia
Posts: 273
Reputation:
Rep Power: 6
Solved Threads: 29
<<several intervening off-topic posts were deleted>>
Well the thread is not solved. Read post no 41
>Is it we have to replace it with fgets?
In your case it's better to do it with fgets
>but if there's too many argument, how to write it. Just want to learn more.
Think. Now you have enough time to think some kind of solution. Search can be similar to list func but you need to change the logic of search func. If you still have a problem then post it.
•
•
•
•
I marked it as solved. Since it is a relatively new thread, I don't see a need to close it.
Well the thread is not solved. Read post no 41
•
•
•
•
Originally Posted by amano
one more thing, i made my edit function like this ( using delete function and then add a new value into contactbook because i don't know how to overwrite the initial value containing in the previous file) Is it we have to use fseek. but how should we know the place in the array.
and you're right with white space thing. Is it we have to replace it with fgets? but if there's too many argument, how to write it. Just want to learn more.
>Is it we have to replace it with fgets?
In your case it's better to do it with fgets
>but if there's too many argument, how to write it. Just want to learn more.
Think. Now you have enough time to think some kind of solution. Search can be similar to list func but you need to change the logic of search func. If you still have a problem then post it.
Last edited by Dave Sinkula : Sep 13th, 2006 at 7:15 pm.
If you want to win, you must not loose (Alan Ford)
•
•
•
•
••••fflush dosn't work for input streams and I think it's system("cls"); instead of system("clear");
system("cls") for windows
system("clear") for unix(knoppix)
the problem right now that i want to cocentrate at is Search function and Delete function. Anybody know. Pls help me. Urgent.......
Why not to use fflush(stdin): FAQ > Explanations of... > Why fflush(stdin) is wrong
What to use instead: FAQ > How do I... (Level 2) > Flush the input buffer
How to clear the screen: FAQ > How do I... (Level 1) > Clear the screen?
In case you ever intend to compile that program as C++, you can't call main() in a C++ program.
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Standard also has
gets() and goto, too. And when you're driving, the brake doesn't have to be used at a red light.Bad practices are bad practices, even when they are allowed. The C standard also allows this program to compile and run:
#include <stdio.h>
int GetDenom(int val,int *den){int i;int dp=0;for(i=1;i<=(val/2);i++){if((val%i)==0){den[dp++]=i;}}den[dp++]=val;return(dp);}
int main(){int i, v;int val,den[100],denp;v=0;for(val=2;val<10000;val++){denp=GetDenom(val,den);if(v<denp)v=denp;printf("%4d",val);printf("(%3d):",denp);for(i=0;i<denp;i++)printf("%3d",den[i]);printf("\n");}printf("v=%d\n",v);return 0;} Age is unimportant -- except in cheese
Yes i completely agree with Mr. WaltP, since old habits die hard. For small exercies it doesnt make a difference, but in the long run it causes a lot of problems. Correct methodology coupled with technical accuracy can only be achieved only if you try for it and want to learn new each day.
Otherwise its the same thing like many people who learn such things the hard way. (eg. building a 3d Game using an external engine).
Hope it helped, bye.
Otherwise its the same thing like many people who learn such things the hard way. (eg. building a 3d Game using an external engine).
Hope it helped, bye.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Mr.? Makes me feel old....

I really wish people would stop saying crap like this. It does make a difference whether large or small. It's just wrong. Period.
Age is unimportant -- except in cheese
•
•
•
•
I really wish people would stop saying crap like this. It does make a difference whether large or small. It's just wrong. Period.
Err.. typing mistake maybe, what i wanted to say was:
"For small programming exercises it may not make a difference for you"...
and the you here is the one who thinks writing clumsy code doesnt make a difference but surely not me.
And by the way i am a proponent of methodological development and good design.
Hope it cleared away the misunderstanding.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
•
•
•
•
Standard also hasgets()andgoto, too. And when you're driving, the brake doesn't have to be used at a red light.
Bad practices are bad practices, even when they are allowed. The C standard also allows this program to compile and run:
I was simply highlighting that it's legal to call in C.
main( ) is just another function in C . Nothing special about it except the return type and parameter list. Though I am not encouraging anyone to call main( ) but you just can't say that it's a bad practise just like that without giving any reason.
There are lot of things like
goto, void * etc whose use is discouraged by lot of people but there can be cases where they can come handy and be used. Even Stroustrup says that goto and void* can be useful in some cases. You can't just blindly say that these are bad practises. Basic problem is that people are ignorant and really don't know where and how to use them properly. Last edited by Grunt : Sep 16th, 2006 at 12:55 am.
The key to eliminating bugs from your code is learning from your mistakes.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
api apple asm assembly x86 programming hla demo blogger blogging c c++ ccna cocoa code coding competition compiler compilers computer debugging developer development errors evaluation framework gdata google high-performance innovation java languages linerider mcse microsystems networking news next object online open oriented planning platform practices programming python rss software step steps sun tools tutorials xml
- Shell Programming (Shell Scripting)
- Programming (C++)
- Where to get started with Web Programming (IT Careers and Business)
- Programming in Linux? (*nix Software)
- Help Me on Symbian(OS) Programming with c++ (C++)
- Good books on Shell Programming/Perl (Perl)
- Efficient Programming (Computer Science and Software Design)
- New To Programming = ME!! (C++)
Other Threads in the C Forum
- Previous Thread: realy fresh to C
- Next Thread: Connecting database using C


Linear Mode