473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

There is really important wrong, but I couldnt find

struct guitar active;
char *buffer_char3;
while(!feof(ptdata))
{
fgets(buffer[0],26, ptdata);
fgets(buffer[1],26, ptdata);
fgets(buffer[2],26, ptdata);
fgets(buffer[3],26, ptdata);
fgets(buffer[4],26, ptdata);
active.serial=integer_analys(buffer[0]);
active.price=integer_analys(buffer[1]);

buffer_char = strtok (buffer[2], bracket);
buffer_char = strtok (NULL, bracket);
buffer_char2 = strtok (buffer[3], bracket);
buffer_char2 = strtok (NULL, bracket);
buffer_char3 = strtok (buffer[4], bracket);
buffer_char3 = strtok (NULL, bracket);

how can I convert buffer_char3 to active.model ( model is char
array of guitar struct component)

I have tried to find for 4 days, I did everything but I couldnt
help me please
Nov 30 '07 #1
2 1330
emre esirik(hacettepe computer science and engineering) wrote:
struct guitar active;
char *buffer_char3;
while(!feof(ptdata))
^^^^^^^^^^^^
This is almost certainly _not_ what you want. Why is this
Pascalism so common? It can't be that any competent C textbook actually
suggests it.
{
fgets(buffer[0],26, ptdata);
fgets(buffer[1],26, ptdata);
fgets(buffer[2],26, ptdata);
fgets(buffer[3],26, ptdata);
fgets(buffer[4],26, ptdata);
Each of the above should be checked for success.
You don't show a declaration of buffer, so I assume it is an
array of char arrays, each of adequate length. Check to make sure.
>

active.serial=integer_analys(buffer[0]);
active.price=integer_analys(buffer[1]);
buffer_char = strtok (buffer[2], bracket);
buffer_char = strtok (NULL, bracket);
buffer_char2 = strtok (buffer[3], bracket);
buffer_char2 = strtok (NULL, bracket);
buffer_char3 = strtok (buffer[4], bracket);
buffer_char3 = strtok (NULL, bracket);
It is rarely right to use strtok on your only copy of a
string, since it is destructive. Note that an array of
char *buffer_char[5];
would parallel the (assumed) declaration of
#define BIGENOUGH 27
char buffer[5][BIGENOUGH];
and allow the use of loops for processing.
Also note that you have destroyed the first values returned by strtok
assigned to the buffer_char* by the second calls.
how can I convert buffer_char3 to active.model ( model is char
array of guitar struct component)
buffer_char3 points to a string. You want to store it in a char array.
Doesn't the extremely obvious copy using any of the strcpy, strncpy,
memcpy, or memmove function work for you.
>
I have tried to find for 4 days, I did everything but I couldnt
help me please
I suspect that you are confused about _what_ you are trying to do. Get
that straight before even thinking about _how_ to do it.
Nov 30 '07 #2
emre esirik(hacettepe computer science and engineering) wrote:

[...]
buffer_char3 = strtok (buffer[4], bracket);
buffer_char3 = strtok (NULL, bracket);

how can I convert buffer_char3 to active.model ( model is char
array of guitar struct component)

I have tried to find for 4 days, I did everything but I couldnt
help me please
Posting a minimal self-contained example, demonstrating the "problem",
will generate more useful help.

My guess is, you should look into how strtok() works.

--
Tor <bw****@wvtqvm.vw | tr i-za-h a-z>
Nov 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
39
by: Antoon Pardon | last post by:
I was wondering how people would feel if the cmp function and the __cmp__ method would be a bit more generalised. The problem now is that the cmp protocol has no way to indicate two objects are...
210
by: Christoph Zwerschke | last post by:
This is probably a FAQ, but I dare to ask it nevertheless since I haven't found a satisfying answer yet: Why isn't there an "ordered dictionary" class at least in the standard list? Time and again...
44
by: Tolga | last post by:
As far as I know, Perl is known as "there are many ways to do something" and Python is known as "there is only one way". Could you please explain this? How is this possible and is it *really* a...
4
by: Nospam | last post by:
<SCRIPT type='text/javascript' language='javascript'> document.write('<img src="http://www.example.com/image1.jpg" width="60" height="60">'); for some strange reason it is not showing the picture
11
by: Miro | last post by:
I created an MDI form and made a child form. On the child form I set the Min / Maximize buttons to false. However when the child form displays, the minimize button and the "restore" button...
19
by: Mary Pegg | last post by:
There's got to be a better way: if (isset($c)) echo $c."<br>"; if (isset($c)) echo $c."<br>"; if (isset($c)) echo $c."<br>"; if (isset($c)) echo $c."<br>"; if (isset($c)) echo $c."<br>"; but...
2
by: quethzal | last post by:
I am using Visual Web Developer 2005 for implementing a web site that requires login. However I made the check for the valid user name and password and show login error in my default.aspx.cs file by...
5
by: emre esirik(hacettepe computer science and enginee | last post by:
/////////////////////// DIVISION FUNCTION //////////////////// void div ( int pol1 , int pol1p , int pol2 , int pol2p) { int r=5,z,i,g,j,k,l,dividend,rising={0}; for (i=0 ; i<6 ; i++)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.