i am trying to read a file and save to array

i wrote one and it worked accept it not reading ot line by line, so i wrote another one but i am trying to make it as function
when i make function call i get this error

read.c:32:13: error: invalid operands to binary * (have ‘char *’ and ‘char *’)

the function should take char* so whats the problem ?

my code

#include <stdio.h>

Nstring *readLine(FILE *file)
    char buffer[1000];
char * Nstring ;
char *line ;

    numstring *result = [ numstring  strc:256];

    int chars;
        if(fscanf(file, "%4095[^\n]%n%*c", buffer, &chars) == 1)
            [res = appendFormat:@"%s", buffer];
    } while(chars == 1000);

    return res;
int main (){
char * Nstring ;
char *line ;
FILE *file = fopen("myfile", "r");
// check for NULL
    Nstring *line = readLine(file);

return 0 ;
3 Years
Discussion Span
Last Post by fedaa91

It looks like you're mixing standard C and Objective-C. Note that this is the C forum, did you mean to post in the Objective-C forum?


** yes ...i am mixing between them ...i dont know the Objective C ...i am learning how to program with C not Objective C ..but i use what i see on the internet and combine it to make specific code ... so definitely i am mixing between them now !


Edited by fedaa91


That's a problem because your code will not compile as C, and if you ask questions in the C forum, the first thing you'll be told is one of the following (depending on how helpful and familiar with Objective-C the person is):

  1. Your code is not C and is wrong.
  2. Your code is Objective-C and you're in the wrong place.

If you want to learn C, learn C, not some bastardization of C and Objective-C that may not compile as either.

Edited by deceptikon


You need headers like

  1. <math.h>
  2. <stdlib.h>
  3. <curses.h> or if you are using microsoft <conio.h>
  4. <stdfx.h>
  5. <graphics.h>



You need headers like
<curses.h> or if you are using microsoft <conio.h>

If you don't know what you're talking about, please don't pretend that you do. Because those of us that know what we're talking about will see through it easily.


ok ,,, i was just asking ,, i am sorry i will write another one with C not Objective C cuz i dont deal with it ,, i thought it was C

thanks for the information though

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.