Solved

scanf question

Posted on 2004-08-03
2
330 Views
Last Modified: 2010-07-27
I've never really used scanf or fscanf before, and I was wondering if it would work for this situation:

I have a file in the format of:

var1=something
var2=somethingelse...

I tried using:
fscanf(f,"%s=%s\r\n",szVar,szVal);

That didn't work since szVar got filled with the entire line.  Can scanf do this, or do I need to do the parsing myself?
0
Comment
Question by:lwinkenb
2 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 125 total points
ID: 11712305
Hi lwinkenb,

> fscanf(f,"%s=%s\r\n",szVar,szVal);

fscanf (f, "%[^=]=%s",szVar,szVal);

make sure that memory referenced by szVar and SzVal is writable

Sunnycoder
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 11712426
Thanks sunny :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ check and remove last word from a string 5 170
Using ANSI C how to Read a .csv file 10 79
IIS Log files on Exchange 2013 server 6 114
delete-remove 14 84
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now