That is not really important . The guy will now the limit of the string. I am just trying to use the shortest function not to get tired =)
Printable View
That is not really important . The guy will now the limit of the string. I am just trying to use the shortest function not to get tired =)
What are you talking about , I am sure guy has a brain to use , and gets is a short function which is useful when you are trying your algorith if it is working.Why would I use a function like fgets(blablalblalblall) ?? It is a must when you are writing a program for a real usage . Stop teaching around!!
gets() is not safe, and as such, it's deprecated. If someone seriously can't write the proper code to use fgets(), something is seriously wrong with their C coding ability and they should learn how to use the function.
"Why would I drive on the right hand side of the road? It's easier to drive in the middle"
Read the FAQ regarding gets.
Is it hard to get?Using c codes is like doing the 4+5 math problem. I just say. When trying your algorithm , gets is shorter and faster to write , so when you are executing the program repeatedly lines dont play hard to change !! Goddd.
Sorry for overreacting , I am just trying to tell you , I am not a kid here messing around. What you know ? I know that . I would be wanting your knowledge when I find a thing to ask. I am not underestimating you . I am sure most of you are better and older than me . But how can you understand that I cant use fgets function by my fgets(blablslnbla) writing. Are you all this hardworking that does not mind to write long sentences when answering a simple question? And also I had a look at FAQ. Yes there are lot of useful things. But that is not that gets thing. A real beginner that knew about strings for a hour would know that. That's what I did.And ZACS find another things for answering people's questions. All you do is telling people see FAQ blblsalblablba... Did you write those , coz I think you have sensual relationship with those lines. Sorryh for overreacting again. But you know what you could answer me this zacs:
--------Code:FILE *fp;
fp=fopen("d.txt","w");
char k;
k=getchar();
while(k!=x) {
fputc(k,fp);
k=getchar(); }
When inputing the chars if I write "car" text file becomes this:
car
But if I input it like "c return a return r return" It becomes
c
a
r
Yea I see enter is the '\n' ,but strings doenst get enter as a \n . But how can File pointers can do that?
1. The FAQ is there for a reason
2. gets is depreciated, use fgets
3. Don't use gets because it's easier to write, that's a stupid excuse.
And for your code, providing your not being a smart ass or sarcastic.
1. Where does 'x' come from?
2. Disregarding x, if you write 'car' and push enter, the stream (stdin in this case) holds 'car\n', therefore the loop will continue (not asking for input) until it's all written to the file. Similar with 'c return a return...'
The stream will hold:
'c\n', then 'a\n' then 'r\n'.
See the FAQ regarding user input.
I didnt write all the things and I forgot to add 'x' .That is not a variable . I want user to write x end of the lne
like this
carx
or like this
c
a
r
x
One writes "car" one writes :
c
a
r
I didnt read all you wrote sorry I gotta go
> so when you are executing the program repeatedly lines dont play hard to change !! Goddd.
I'm sorry, what was that? fgets has no affect on repeated execution anymore than gets does, except that when gets tries to read everything the program explodes. If you even run into a situation where repeated execution even matters, it's bad news bears. Goddd.
But this has been argued by people smarter than us. I do agree that everyone should chill out now. Points made. Thread over.
citizen , like everybody else , you did not even get one of the points I have made. And are you talking about smartness? Stop there , you can not know who is smarter than who. And you have no right to question my intelligence ,furthermore I am sure I have nothing to talk about it with you ; because I have seen all the education you get in US and other foreign countries.You take the courses on your 18 when we take them at our 13-14 . So shut your business here and go away . And I am tired of this topic , OFCOURSE FGETS IS BETTER THEN GETS. I MEAN THERE , I WAS TRYING TO POST A QUESTION QUICKLY SOOO ; GETS(S) IS SOOOO MUCH SHORTER THAN FGETS(S,N,STDIN) I WROTE IT as GETSS?? SO WHAT ???ARE YOU HAVING A PLEASURE TO CLARIFY YOUR QUESTIONABLE WISDOM TO PEOPLE?? THE TOPIC IS DONE I JUST WANT ZAC TO ANSWER MY CAR THING.NOT BECAUSE I AM QUESTIONING HIS KNOWLEDGE ; I WONDER THAT , AND RIGHT NOW I DONT WANT TO LOSE TIME . BECAUSE I GOTTA FILL A DAMN SULPHAMATE BATH!
Ahh , also I do not need the ANSWER zac will do . cOZ I saw the reason.You should learn that posting posting and posting with your empty answering pleasure does not mean anything and I really wonder are you in university or something , how old are you , what do you do for life ?
I have moved the gets() specific discussion away from the other thread so StrikeMech can get a better response later.
ozumsafa, the FAQ clearly states that gets() is unsafe. That appears to be the consensus among the community here, and from what I see that is correct. You are free to use it in your own code, of course, but kindly refrain from suggesting it to others on this message board.
If you want to pose a question, please start a new thread.
> Stop there , you can not know who is smarter than who.
Right, but I happen to know that other people in other places have had this argument (like the clc newsgroup) and people have made smarter statements in support of gets. They're probably smarter than both of us.
I suppose the real reason I get involved in threads like this one is because I like to speak up when the heat of the argument has died down a bit. I will admit this isn't a perfect place, but I have noticed that you've taken things very personally which doesn't work well anywhere. Zach put it rather bluntly, but stop apologizing, it's fine: understand that people here help others as part of a team effort - let them say what they want to.
If you want to be bothered less by corrections, be right, and only post code after it's safe to use. Hope that helps.
I put it bluntly due to his stubbornness on the other post, I apologize. Although I don't think that constitutes his rudeness. The boards are about helping, not raging it at each other.Quote:
Zach put it rather bluntly, but stop apologizing, it's fine: understand that people here help others as part of a team effort - let them say what they want to.
Thank you citizen , of course that helps . But really , I know my self , and I can't stand when people compare my intelligence with other people without knowing me personally. Yea the guys from ANSI C labaratories are probably really smart. But I am at the beginning of that road.And so anyone could not know if I would be better or worse. So that is the way I am. After I failed , I think I can stand all predictions about me . Anyway , I am sorry , I overeacted. And like I Said , of course I know fgets is safer than gets . I just use gets when I know how long I declared my string , so I dont enter longer inputs when I am trying my program. If I do , It will be off. I do not question the safety difference between gets and fgets. The reason of my overreacting was that teaching attitude towards everything I say. And again godd , what is with that FAQ , I know they are there, and I tried to explain many times that I know gets is bad and I know why gets is bad and also I said I never need one to tell that to me , in any other way I couldnt think to be precious brain for the world. So that was my concern. Thank you for not deleting and moving it somehow. Take care . I am also glad I am not banned , here looks like a good place to ask some questions... Good work on the site..
And also I really wonder , what do people do of this site for example you citizen. I dont want personal knowledge. I just wonder if the people answering these questions are from university our after graduate , or professional programmers or anything??
We have professionals, students, idiots, trolls, and fine souls. :) Pretty much a mixed bag as far as knowledge or experience goes. It's a well-rounded place, but get to know and trust the moderators especially. If they answer something it's usually very correct.
Actually, citizen, being a Perfect Gentleman, included himself in the comparison :) "Smarter" here is not so much about being more intelligent in general, but about having more expertise in this area.Quote:
I can't stand when people compare my intelligence with other people without knowing me personally
Yes, but remember that others may need you to tell them, and as such you should not suggest to them something you know to be 'bad' unless you want to give ample warning. It is usually simpler to just suggest something that is 'good'.Quote:
I know gets is bad and I know why gets is bad and also I said I never need one to tell that to me
This thread has served its purpose, i.e., to clarify that you know gets() vs fgets() and hopefully will make suggestions to others accordingly.Quote:
Thank you for not deleting and moving it somehow.
Questions pertaining to the composition of the group of users who answer questions should be posed in General Discussions. That said, I can tell you that the answer is all of the above.Quote:
I just wonder if the people answering these questions are from university our after graduate , or professional programmers or anything?
Thank you again , and sorry again for being such a raging barbarian around. I wasnt like that normally , somehow I changed a little bit on that topic. I think I have gained a level and I don't know which skill to raise , and this actually justify that you have some trolls here , I must have killed one. (Playing too much frp :S)
And I forgot to add. I know he is being a perfect gentlemen by adding himself in the comparison. But you know that kind of people who says like this:
"maannn they are so smarter than us , we can never be there"...
I stopped being around people saying those comparison and discouraging things. That is why I am raging at all. You can never know if a villager who is just hoeing the soil is much smarter than me. That is my point...
No worries. Do not be discouraged from helping where you can. Just do your best not to give faulty advice.Quote:
Thank you again
*thread closed*