473,397 Members | 2,028 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,397 software developers and data experts.

Please help me!

Okay so I'm REALLY new at this whole C stuff :-/ and I need some help. Im workin on a program and so far this is what I have..

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

#define MAXL 200
#define MAXSNG 99

void FRNL (char input[MAXSNG][MAXL], int size)
{
int i, j;
for (i=0; i<size; i++)
{
j=0;
while (input[i][j]!= '\n' && input[i][j]!='\r')
{ j++;
}
input[i][j] = '\0' ;
}
}

int main()
{
FILE *in_f, *out_f;
int playtimes[MAXSNG];
int i=0;
char names [MAXSNG][MAXL];
in_f = fopen("songdata.txt", "r");
assert(in_f);
out_f = fopen("output.txt", "w");

if (!in_f)
{
printf("could not open file\n");
exit(0);
}

while (fscanf (in_f, "%d", &playtimes[i]==1)
{
fgets(names[i], MAXL, in_f); i++}
}

FRNL (names, i);
for (j=0; j<i; j++)
{
printf(%d %s", playtimes[j], names[j];
}

return 0;
}


when I compile thought I get these errors:
program4.c:37: warning: comparison between pointer and integer
program4.c:37: warning: format argument is not a pointer (arg 3)
program4.c:38: error: syntax error before '{' token
program4.c:39: error: syntax error before '}' token
program4.c:26: warning: unused variable `names'

and I can't figure out why! I know that I did this same code in class today and it compiled fine, but i must have missed something in my notes.. because now it wont work :( Can you help me? :-D
Nov 8 '06 #1
2 1233
r035198x
13,262 8TB
Okay so I'm REALLY new at this whole C stuff :-/ and I need some help. Im workin on a program and so far this is what I have..

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

#define MAXL 200
#define MAXSNG 99

void FRNL (char input[MAXSNG][MAXL], int size)
{
int i, j;
for (i=0; i<size; i++)
{
j=0;
while (input[i][j]!= '\n' && input[i][j]!='\r')
{ j++;
}
input[i][j] = '\0' ;
}
}

int main()
{
FILE *in_f, *out_f;
int playtimes[MAXSNG];
int i=0;
char names [MAXSNG][MAXL];
in_f = fopen("songdata.txt", "r");
assert(in_f);
out_f = fopen("output.txt", "w");

if (!in_f)
{
printf("could not open file\n");
exit(0);
}

while (fscanf (in_f, "%d", &playtimes[i]==1)
{
fgets(names[i], MAXL, in_f); i++}
}

FRNL (names, i);
for (j=0; j<i; j++)
{
printf(%d %s", playtimes[j], names[j];
}

return 0;
}


when I compile thought I get these errors:
program4.c:37: warning: comparison between pointer and integer
program4.c:37: warning: format argument is not a pointer (arg 3)
program4.c:38: error: syntax error before '{' token
program4.c:39: error: syntax error before '}' token
program4.c:26: warning: unused variable `names'

and I can't figure out why! I know that I did this same code in class today and it compiled fine, but i must have missed something in my notes.. because now it wont work :( Can you help me? :-D
Look at the error messages and the line numbers. They give you a hint on how to remove the errors
eg &playtimes[i]==1 compares an address with an integer

and

fgets(names[i], MAXL, in_f); i++}

has an extra }
Nov 8 '06 #2
ok I can't figure out what i did wrong here
eg &playtimes[i]==1 compares an address with an integer

can you help me?
Nov 8 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.