Okay, so if I declare c as an int could implement the same logic and just typecast c to char?
Type: Posts; User: rmmstn
Okay, so if I declare c as an int could implement the same logic and just typecast c to char?
I want to count the number of occurrences of each character found in the input and print it to the output.
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
...
I want to make a menu that classifies animals into insects, birds, mammals and fishes with specific characteristics for each of these (using composite variables). I thought I'd use a nested switch...
I have the following .txt file:
1 7 9 12
8 4 22 5
4 9 0 10
15 2 3 14
I wanna print the lines in descending order based on the average value on each individual line.
...
Thank you! If I wanna work with dynamically allocated arrays is this the way to go?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define MAX 100
unsigned...
I'm trying to implement a function that receives an array of integers and its capacity and fills the array with all the values read from the keyboard which are prime numbers, without overflowing it,...
Thanks, now I'm trying to get the maximum hour from the file and if two hours are equal then check their minutes to sort them in descending order. Would it be easier to use a structure in this case?...
I want to implement a program that reads data from a file specified as a command-line argument, having the following format:
username, hh, mm
where the fields are separated by a comma and might...
I'm kind of a newbie in C and I haven't learned about setlocale yet
Okay I have no more warnings:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define MAX 100
unsigned checkWord(char *word)
{
Haha, that's actually what I wanted to do so I would spare myself of all the work but I thought I'd solve it the way it was stated first
Write a function that reads data from standard input until EOF is found and returns the maximum of the real numbers found into the input.
We consider a real number as a number composed of two...
I want to write a function that splits a string into words (strings with no whitespace), returning a (dynamically allocated) array of pointers to (dynamically allocated) copies of the words in the...
Thanks a lot, it's so much clearer now! Just to make sure I understood fully, you wrote i < cap - 1 because we don't take the terminator '\0' into a account, right?
Damn, yeah I treated it as an array of characters by mistake and I wanted to make sure that it is empty and null-terminated in the beginning. What would be the alternative to make sure my array isn't...
Is this correct?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void wordAdresses(char *s, int *ptr_arr, int cap)
{
ptr_arr[0] = '\0';
unsigned i, countWords = 0;
The task is:
Write a function that reads data from standard input until EOF is found and returns the maximum of the real numbers found into the input. We consider a real number as a number composed...
Task: Write a function that takes as parameter a string, an array of pointers and its length and fills the array with addresses to the beginning of each (whitespace-separated) word in the string...
Thanks! :D
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
char* aux;
printf("Program name is %s\n", argv[0]);
I have the following task:
Write a program that reorders the command-line argument array argv[], placing all strings that start with '-' first, followed by all other strings.
#include...
Thanks a lot! I copy-pasted the task so I don't think I should add a space. I'll keeps the little things in mind for future code :D
I did the task:
Implement a function that receives a C-styled string (s) and an array of characters (buff) together with its capacity and concatenates into buff all the words from s which are...
It's working now, thank you!
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define MAX 100
int checkWord(char word[])
{
size_t len = strlen(word);
if(word[0] != '&' || word[len-1] != ';')
...
Yeah, I added that afterwards because I didn't know what else to try, but it doesn't work without it either.