Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

when I try to use those functions it sends this error:

main.cpp: In function ‘int main()’:
main.cpp:11:17: error: conversion from ‘int’ to non-scalar type ‘fpos_t {aka _G_fpos_t}’ requested
main.cpp:18:20: error: cannot convert ‘fpos_t {aka _G_fpos_t}’ to ‘FILE* {aka _IO_FILE*}’ for argument ‘1’ to ‘int fgetpos(FILE*, fpos_t*)’

The code is:


struct registro{
        char nombre[5];

int main()
FILE *fp;
registro datos[5];
fpos_t posicion=5;

fp = fopen("nombres.txt","w"); //CREA UN ARCHIVO DE TEXTO

printf("ingrese nombre: ");

fwrite(&datos[1],5,1,fp); //ESCRIBE EL VALOR DE DATOS EN FP, CON UN TAMAÑO DE 5

If you see any error please help.

share|improve this question

closed as off-topic by Radu Rădeanu, Braiam, karel, psusi, chronitis Oct 22 '13 at 10:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Radu Rădeanu, Braiam, karel, psusi, chronitis
If this question can be reworded to fit the rules in the help center, please edit the question.

All i want is a program that starts writting the text after a certain position... but i just cant get it to work – Rafa Mena Oct 23 '13 at 15:31
up vote 0 down vote accepted

Looks more like a stackoverflow kind of question but anyway, from what I can get from the error message, the problem is with the posiciion=5 part of the code. You are assigning an integer to a non-integer type fpos_t and that is causing both errors. try it without =5 and see if it works.

share|improve this answer
i gave up, this is the new code: #include<stdio.h> int main(){ FILE *fp; fpos_t position=; fp = fopen("file.txt","w"); fsetpos(fp,&position); fputs("This isnt working",fp); fclose(fp); } all i want is to creat a file where the text starts at position 10. I already did what you said, to delete =5 and it compiled.. but well, the text started from the begining, how can i get it to start at a designed position? – Rafa Mena Oct 23 '13 at 15:28
I really suggest you post your coding related question on SO, other than me not really knowing how to help, it is not the most convenient way to do that here in comments. Really sorry :( – arsaKasra Oct 23 '13 at 17:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.