Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1093189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:47:34+00:00 2026-05-16T23:47:34+00:00

My instructor said the way to start this is to use the getline() function

  • 0

My instructor said the way to start this is to use the getline() function from out book, then get the numbers from the line, then have those numbers in matrix form, I do not understand why I would use getline?

//eventually this code should take in a square matrix and from 2×2 to 6×6
//the plan is to get it to read in a line, then get the numbers from the line,
//then print out the numbers in a matrix form. That is the goal for today.
//later I will try to get the actual matrix part working

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

//error list for error checking will need later I guess (from my notes)
#define ENDOFFILE -1 
#define TOOMANYNUMS -2
#define LIMIT  256

//functions declared
int get_line(char line[], int);

//main
main(){
char line[255];
int num[6];
printf("Please input numbers %c: ", line);
get_line(line,LIMIT);


}

//functions 
  int get_line(char s[],int lim){
  int c, i;
    for (i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
  s[i] = c;
if(c=='\n'){
s[i]=c;
  ++i; 
}
s[i]='\0';
return i;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:47:34+00:00Added an answer on May 16, 2026 at 11:47 pm

    The getline(char[], int) function reads characters from the console with getchar() and stores them in the array s[]. The array s[] points at the same memory as the line[] array in the main() function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out something with EF4 Code Only. If i use
Most of the implementations I find require a hardware instruction to do this. However
My instructor gave us example code that is very similiar to the code below.
Instruction on accessing a interface to an application, in plain C/C++ without : MFC
What's the instruction to cause a hard-break in Xcode? For example under Visual Studio
Is there a CIL instruction to exchange the first two elements in the stack?
Can anybody provide some instruction on how to setup a war file to show
Intel is set to release a new instruction set called AVX , which includes
I want to add text to speech user guided instruction to my applications. Where
Imagine I have the following: inFile = /adda/adas/sdas/hello.txt # that instruction give me hello.txt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.