ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The only problem is they almost seem to technical for me. Is there anything with easier readability because I would like to start learning the C functions programming is getting pretting boring without actually having the ability to learn these functions.
Books or anything as long as they explain in more detail.
You might consider some books too. Sam Publications are usually a good first book. If you are just learning C for fun, then it's ok. Now, if you actually have a given application/dream in mind, you may be starting with an over-difficult language where the same could be accomplished in an easier, more enjoyable way
Thanks for that. I have another question but it's more of a "need coding help" question.
Anyway here's my problem. I have a file that I want to read using a "stdlib.h" function and then change the data that it has read in. The file is below:
Code:
Accredited Funds: 4000
Funds Remaining: 400
The "Accredited Funds" and the "Funds Remaining" came from ouput in an earlier program using "fprintf();". Now what I would like to do is read in the "4000" and the "400" into two different variables and manipulate them according to what the user inputs. Is this possible? And if so how would I go about getting the "4000" and the "400" into two different variables? Can someone give me a small example please.
That's very basic. scanf is used to get input from the keyboard, while printf is used to output. C++ equivalents should be cout and cin. You might really consider a few tutorials, just to get you used with the syntax.
For scanf, the C99 standard states "The fscanf function returns the value of
the macro EOF if an input failure occurs before any conversion." But glibc's
scanf does not respect conversions for which assignment was surpressed, even
though the standard states that the value is converted but not stored.
- First, do some tutorials for C or grab some books. You will need it.
- Second: I would try be to pick up a more modem language as C++ or Java. Those languages has a much clear syntax and it's easier to find tutorials about them all over the net. Good C tutorials are not as easy to find as it was before. Same goes to books. I found very difficult to find C programming books, whereas Java and C++ are all over the shelves.
- Third: Some scripting languages are extremely powerful, as python, and has an even cleaner syntax, while being still OOP and giving you full control how it works, even to pointers. Works with nearly every API out there, from gtk to OpenGL.
Regards!
Last edited by Mega Man X; 10-28-2005 at 11:26 AM.
Originally posted by Mega Man X That's very basic. scanf is used to get input from the keyboard, while printf is used to output. C++ equivalents should be cout and cin. You might really consider a few tutorials, just to get you used with the syntax.
- First, do some tutorials for C or grab some books. You will need it.
- Second: I would try be to pick up a more modem language as C++ or Java. Those languages has a much clear syntax and it's easier to find tutorials about them all over the net. Good C tutorials are not as easy to find as it was before. Same goes to books. I found very difficult to find C programming books, whereas Java and C++ are all over the shelves.
- Third: Some scripting languages are extremely powerful, as python, and has an even cleaner syntax, while being still OOP and giving you full control how it works, even to pointers. Works with nearly every API out there, from gtk to OpenGL.
Regards!
I know exactly what "scanf" does and I know a bit about OOP. I do not want to use it to get input from the keyboard, I want to use a function to get input from a file. For example the below bit of info is my file... a text ASCII file:
Code:
Accredited Funds: 4000
Funds Remaining: 400
This file was made using a program who had two variables, "1.) Accredited Funds" and "2.) Funds Remaining".
The program did the math and wrote this info to the file, now I wish to "read" that info from the file and into another varialbe, so the "4000" will be stored in one variable and the "400" will be stored in the another variable; thus I will have two variables in my new program one of them containing the value "4000" and one of them containing the value "400" and the value in these variables would have came from "Accredited Funds" and "Funds Remaining" within my .txt file above.
Originally posted by Mega Man X Now I understand . Sorry. In this case, you need to use fopen to open a file and when you done, fclose to close it. Take a look here:
Yep, thanks for your help but I know this too. As I said I am trying to "read" into RAM the variables that's in the txt file. Preferably into the same variable (i.e "Accredited Funds" and "Funds Remaining"). Think of this file as being an .INI extension file.
I mean I want to use this file in exactly the same way as a normal program would use an .INI file. You know like whatever program that uses an .INI file will open the file, and edit it (this is what I want to do). But it treats certain settings within the file just as if it was a variable in memory(that being the program can change it's value). I don't want to "Append" text, I don't want to "Write" over any text, all I want to do is treat the two names I used in the file as variables. Accredited Funds one variable that holds a value in RAM and Funds Remaining that holds a value in RAM also.
Put very simply... as I am even starting to confuse myself, I want to change the numbers in the file but not write over anything else except the numbers.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.