Solved

scanf question

Posted on 2004-08-03
2
324 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

932 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

9 Experts available now in Live!

Get 1:1 Help Now